导出excel,有没有不调用excel com组件的办法呢?
----------------------------------------------
调用com组件进行导出是可以实现,但是对客户机的依赖性太大,
客户机的版本多种多样,
我想问,能不能实现,用纯托管代码,不要基于excel就能导出excel文件,
这样,只要客户的机器上装了.net,就能完成导出excel的工作,可以实现吗

解决方案 »

  1.   

    http://www.cnblogs.com/kakaluote/articles/985021.html
      

  2.   

    csv就是纯文本文件呀,与 txt 没有本质区别。
    csv用excel直接打开是不行的,必须用导入向导才行呀。
      

  3.   

    参考:
    Export a DataSet to Microsoft Excel without the use of COM objects
      

  4.   

    关键是你要导出为何种格式的文件,
    既然 csv 不行, 楼上的 excelML 标记不行?难不成要用二进制文件格式的 excel 文件,
    可是微软公开过那个文件格式么?好像有个 vc 的库可以, 但是如何应对版本更新?标记格式的还不错了.
      

  5.   

    导出到 Excel 中多个 Sheet 的方法http://dotnet.aspx.cc/file/Export-Gridview-To-Excel-With-Multi-Sheet.aspx
      

  6.   

    小东西,简单好用:
    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);      }  }
      

  7.   

    上个代码太乱了:
    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 }