(C#)利用Aspose.Cells组件导入导出excel文件
来源:互联网 发布:淘宝卖家和快递合作 编辑:程序博客网 时间:2024/06/10 08:46
来源:http://blog.csdn.net/weiky626/article/details/7514637
Aspose.Cells组件可以不依赖excel来导入导出excel文件:
导入:
- public static System.Data.DataTable ReadExcel(String strFileName)
- {
- Workbook book = new Workbook();
- book.Open(strFileName);
- Worksheet sheet = book.Worksheets[0];
- Cells cells = sheet.Cells;
- return cells.ExportDataTableAsString(0, 0, cells.MaxDataRow + 1, cells.MaxDataColumn + 1, true);
- }
导出:
- private static void Export<T>(IEnumerable<T> data, HttpResponse response)
- {
- Workbook workbook = new Workbook();
- Worksheet sheet = (Worksheet)workbook.Worksheets[0];
- PropertyInfo[] ps = typeof(T).GetProperties();
- var colIndex = "A";
- foreach (var p in ps)
- {
- sheet.Cells[colIndex + 1].PutValue(p.Name);
- int i = 2;
- foreach (var d in data)
- {
- sheet.Cells[colIndex + i].PutValue(p.GetValue(d, null));
- i++;
- }
- colIndex = ((char)(colIndex[0] + 1)).ToString();
- }
- response.Clear();
- response.Buffer = true;
- response.Charset = "utf-8";
- response.AppendHeader("Content-Disposition", "attachment;filename=xxx.xls");
- response.ContentEncoding = System.Text.Encoding.UTF8;
- response.ContentType = "application/ms-excel";
- response.BinaryWrite(workbook.SaveToStream().ToArray());
- response.End();
- }
0 0
- (C#)利用Aspose.Cells组件导入导出excel文件
- (C#)利用Aspose.Cells组件导入导出excel文件
- 利用Aspose.Cells组件导出excel文件
- Aspose.Cells Excel导出导入
- 利用Aspose.Cells 组件导出数据到excel
- 利用Aspose.Cells组件导出图片
- 利用Aspose.Cells和Excel模板导出复杂的统计数据
- WinForm使用Aspose.cells利用模板导出Excel
- MVC利用Aspose.Cells.dll实现Excel数据导入数据库
- 使用Aspose.Cells组件生成Excel文件实例
- Aspose.Cells读取excel文件
- aspose.cells导出EXCEL分页分组函数
- DataTable 用Aspose.Cells导出Excel
- Aspose.Cells、NPOI、MyXls导出Excel
- 导出excel设置样式(Aspose.Cells)
- 导出excel设置样式(Aspose.Cells)
- 利用Aspose.Cells实现万能导出
- C# winform 导出导入Excel/Doc 完整实例教程 使用Aspose.Cells.dll——第二篇
- 数据结构之常见排序算法汇总
- [cocos2d-x学习笔记][入门基础][塔防]塔防游戏中箭塔旋转并攻击实现
- 死锁
- 遍历Map的四种方法
- Oracle基本数据改变原理浅析(redo与undo)--oracle核心技术读书笔记一
- (C#)利用Aspose.Cells组件导入导出excel文件
- NOSQL数据库读书笔记(基础知识)
- uva529Addition Chains
- UVa10371 - Time Zones(时区转换)
- 常见从网络上请求数据流程
- hdu 4993 Revenge of ex-Euclid(水题)
- 【动态树X脑残错误】hdu5002
- android调用浏览器网络搜索选中文本的方法。
- HDU Walk