Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Library to write an Excel file

Tags:

c#

.net

excel

I am using Microsoft Excel Interop library for exporting Excel file. However, the limit of this library is that:

  • Require the user's computer must have Microsoft Excel.
  • When write the content, Microsoft Excel must be opened to automate.
  • To save file, user must do manually: click on File -> Save.

I need a library:

  • Write the content to memory with Excel format.
  • Save this content to file programmatically.

Notes: I use .net 2.0 and C#.

Thanks.

like image 353
Leo Vo Avatar asked Mar 22 '11 02:03

Leo Vo


3 Answers

I have used EPPlus for .xlsx reading/writing and it has worked great

like image 169
BrandonAGr Avatar answered Nov 16 '22 23:11

BrandonAGr


I think the only way to achieve this without having Excel installed is to just write the file format directly. Microsoft documented the file format a few years ago. You can find them at http://msdn.microsoft.com/en-us/library/cc313118.aspx.

Update I've just found EPPlus. Check it out at http://epplus.codeplex.com/

like image 1
Andrew Cooper Avatar answered Nov 16 '22 22:11

Andrew Cooper


You can use an ODBC or OLE connector to read and write an Excel file. However, I am not sure if you can create a file with it, you might need to keep a dummy-empty file with the correct layout.

Update: It is, accordingly to comment below from @Joel Gauvreau possible to create an excel file using this technique.

Links: http://support.microsoft.com/kb/257819

http://www.codeguru.com/cpp/data/mfc_database/microsoftexcel/article.php/c1131

like image 1
stefan Avatar answered Nov 17 '22 00:11

stefan