Asp.net & Aspose.cells 导出
protected void btnExport_Click(object sender, EventArgs e)
{
DataTable tbBooks = (DataTable)Session["Books"];
if (tbBooks == null)
{
return;
} try
{
Workbook newWorkBook = NewExcel();
Aspose.Cells.Worksheet newSheet = newWorkBook.Worksheets[];
Cells newCells = newSheet.Cells; if (tbBooks != null)
{
for (int i = ; i < tbBooks.Rows.Count; i++)
{ for (int j = ; j < tbBooks.Columns.Count; j++)
{ newCells[i+1, j].PutValue(tbBooks.Rows[i][j].ToString());
}
}
}
newWorkBook.Save("result.xlsx", Aspose.Cells.FileFormatType.Excel97To2003, Aspose.Cells.SaveType.OpenInExcel, Response);
}
catch (Exception ex)
{
MessageBox.Show(this, "导出产品信息库出错,详细错误为:" + ex.Message);
}
} public Workbook NewExcel()
{
DataTable table = (DataTable)Session["Books"];
Workbook newWorkBook = new Workbook();
Aspose.Cells.Worksheet sheet = newWorkBook.Worksheets[];
Cells cells = sheet.Cells; Aspose.Cells.Style style = newWorkBook.Styles[newWorkBook.Styles.Add()];//新增样式
style.HorizontalAlignment = TextAlignmentType.Center;
style.Font.Size = ;
style.Font.Color = System.Drawing.Color.Red;
cells.SetRowHeight(, ); for (int i = ; i < table.Columns.Count; i++)
{
cells[, i].PutValue(table.Columns[i].ColumnName);
cells[, i].SetStyle(style);
cells.SetColumnWidthPixel(i, );
}
return newWorkBook;
}
Asp.net & Aspose.cells 导出的更多相关文章
- Aspose.Cells导出Excel(1)
利用Aspose.Cells导出excel 注意的问题 1.DataTable的处理 2.进行编码,便于中文名文件下载 3.别忘了Aspose.Cells.dll(可以自己在网上搜索) public ...
- C#使用Aspose.Cells导出Excel简单实现
首先,需要添加引用Aspose.Cells.dll,官网下载地址:http://downloads.aspose.com/cells/net 将DataTable导出Xlsx格式的文件下载(网页输出) ...
- Aspose.Cells导出Excel(2)
DataTable dtTitle = ds.Tables[]; DataTable dtDetail = ds.Tables[]; int columns = dtTitle.Columns.Cou ...
- C#+Aspose.Cells 导出Excel及设置样式 (Webform/Winform)
在项目中用到,特此记录下来,Aspose.Cells 不依赖机器装没有装EXCEL都可以导出,很方便.具体可以参考其他 http://www.aspose.com/docs/display/cells ...
- Asp.net & Aspose.cells 导入
Workbook workBook = new Workbook(this.fuFile.FileContent); Aspose.Cells.Worksheet sheet = workBook.W ...
- 利用Aspose.Cells导出Datatable数据
面对一些的格式各样的到处数据的要求,自学了一点 Aspose.Cells中操作Excel知识,如下代码: /// <summary> /// DataTable导出Excel /// &l ...
- aspose.cells导出Demo
/// <summary> /// 导出excel /// </summary> /// <param name="list"></par ...
- C# 使用Aspose.Cells 导出Excel
今天在工作中碰到同事用了一种新型的方式导入excel,在此做个学习记录. 插件:Aspose.Cells 第一步:准备好导出的模板,例子: C#代码: #region 验证数据 if (model = ...
- Aspose.Cells 导出 excel
Aspose.Cells.Workbook book = new Aspose.Cells.Workbook(); Aspose.Cells.Worksheet sheet = book.Worksh ...
随机推荐
- 行人检测4(LBP特征)
参考原文: http://blog.csdn.net/zouxy09/article/details/7929531 http://www.cnblogs.com/dwdxdy/archive/201 ...
- SSIS教程:创建简单的ETL包 -- 3. 添加日志(Adding Logging)
Microsoft Integration Services 包含日志记录功能,可通过提供任务和容器事件跟踪监控包执行情况以及进行故障排除. 日志记录功能非常灵活,可以在包级别或在包中的各个任务和容器 ...
- 【转】前端——实用UI组件库
Angular UI 组件 ngx-bootstrap 是一套Bootstrap 组件 官网:https://valor-software.com/ngx-bootstrap/#/ github: h ...
- Golang报错mixture of field:value and value initializers
Golang 在使用匿名成员初始化时,如果出现 mixture of field:value and value initializers 是因为初始化的方式不对,见代码: package main ...
- git pull和git pull --rebase的使用
使用下面的关系区别这两个操作: git pull = git fetch + git merge git pull --rebase = git fetch + git rebase 现在来看看git ...
- OC与JS交互之WKWebView
上一篇文章我们使用了JavaScriptCore框架重写了之前的示例,iOS8苹果偏爱HTML5,重构了UIWebVIew,给我们带来了WKWebView,使其性能.稳定性.功能大幅度提升,也更好的支 ...
- centos 网络很慢且无法远程登陆的解决办法
安装了centOS,但是发现网速实在是卡得几乎不能上网,连百度都打不开 后来想到偶然记得有一次看过一段话,说到关闭ipv6,测试来一下,果然有效,关闭来ipv6打开网速飞快. 关闭方法,在/etc/m ...
- python学习之老男孩python全栈第九期_day026知识点总结——封装、property、类方法、初识反射
一. 封装 class Room: def __init__(self, name, length, width): self.__name = name self.__length = length ...
- python学习之老男孩python全栈第九期_day021知识点总结——包、异常处理
一. 包 # 把解决一类问题的模块放在同一个文件夹里 -- 包 # 创建目录代码# import os# os.makedirs('glance/api')# os.makedirs('glance/ ...
- 在 :after/ :before 使用 font awesome web Icon
.element { position: relative; } /*replace the content value with the corresponding value from the l ...