导出excel,有没有不调用excel com组件的办法呢?
----------------------------------------------
调用com组件进行导出是可以实现,但是对客户机的依赖性太大,
客户机的版本多种多样,
我想问,能不能实现,用纯托管代码,不要基于excel就能导出excel文件,
这样,只要客户的机器上装了.net,就能完成导出excel的工作,可以实现吗
----------------------------------------------
调用com组件进行导出是可以实现,但是对客户机的依赖性太大,
客户机的版本多种多样,
我想问,能不能实现,用纯托管代码,不要基于excel就能导出excel文件,
这样,只要客户的机器上装了.net,就能完成导出excel的工作,可以实现吗
解决方案 »
- 今天终于有分了, 再发一贴向大家请教, 可能用正则来做会简单和高效一些.
- C#.net 修改代码之后,程序没有发生变化
- C#中用dateTimePicker1.Value.Date问题...急
- ucs2转成string
- 发现微软的一个bug。。。
- 小弟在制作数码管取模软件时遇到了些问题
- 小问题:为什么我在C#中开发的PDA程序不能显示输入法呀!
- 如何把程序中用到的图标、图象之类的文件全部编译到一个EXE中?
- c#程序如何打包呀!在没有按runtime的机子上使用!
- 我没有 vs.net,只安装了Framework,我要怎样才能写C#程序并运行起来?
- oracle插入语句返回对应数据的自增长字段怎么做????
- C# 注册表查询与删除问题
csv用excel直接打开是不行的,必须用导入向导才行呀。
Export a DataSet to Microsoft Excel without the use of COM objects
既然 csv 不行, 楼上的 excelML 标记不行?难不成要用二进制文件格式的 excel 文件,
可是微软公开过那个文件格式么?好像有个 vc 的库可以, 但是如何应对版本更新?标记格式的还不错了.
http://code.google.com/p/excellibrary///create new xls file string file = "C:\\newdoc.xls"; Workbook workbook = new Workbook(); Worksheet worksheet = new Worksheet("First Sheet"); worksheet.Cells[0, 1] = new Cell((short)1); worksheet.Cells[2, 0] = new Cell(9999999); worksheet.Cells[3, 3] = new Cell((decimal)3.45); worksheet.Cells[2, 2] = new Cell("Text string"); worksheet.Cells[2, 4] = new Cell("Second string"); worksheet.Cells[4, 0] = new Cell(32764.5, "#,##0.00"); worksheet.Cells[5, 1] = new Cell(DateTime.Now, @"YYYY\-MM\-DD"); worksheet.Cells.ColumnWidth[0, 1] = 3000; workbook.Worksheets.Add(worksheet); workbook.Save(file); // open xls file Workbook book = Workbook.Load(file); Worksheet sheet = book.Worksheets[0]; // traverse cells foreach (Pair<Pair<int, int>, Cell> cell in sheet.Cells) { dgvCells[cell.Left.Right, cell.Left.Left].Value = cell.Right.Value; } // traverse rows by Index for (int rowIndex = sheet.Cells.FirstRowIndex; rowIndex <= sheet.Cells.LastRowIndex; rowIndex++) { Row row = sheet.Cells.GetRow(rowIndex); for (int colIndex = row.FirstColIndex; colIndex <= row.LastColIndex; colIndex++) { Cell cell = row.GetCell(colIndex); } }
using System; 02 using ExcelLibrary.SpreadSheet; 03 04 class ExcelLibraryTest 05 { 06 public static void Main(string[] args) 07 { 08 09 Workbook workbook = new Workbook(); 10 Worksheet worksheet = new Worksheet("Persons"); 11 12 worksheet.Cells[0, 0] = new Cell("ID"); 13 worksheet.Cells[0, 1] = new Cell("Name"); 14 worksheet.Cells[0, 2] = new Cell("Age"); 15 16 worksheet.Cells[1, 0] = new Cell("1"); 17 worksheet.Cells[1, 1] = new Cell("Unmi"); 18 worksheet.Cells[1, 2] = new Cell("xxx"); 19 20 //可以下列方法设置额外的信息 21 //worksheet.AddPicture; worksheet.ExtractPicture;worksheet.Cells.ColumnWidth 22 23 workbook.Worksheets.Add(worksheet); 24 workbook.Save(@"c:\test.xls"); 25 } 26 }