Creating Excel Files Using C #

I need to create an excel file via C #. I read a few places that create an XML document - is this the easiest way to do this? I need to have several named tabs and be able to indicate that certain cells are text, date, number, etc. Any suggestions or good examples?

+7
c # xml excel
source share
7 answers

You need the System.IO.Packaging API - this will allow you to generate .xlsx documents, as described in Inserting values โ€‹โ€‹into Excel 2007 cells . The Excel 2007 format can also be used by Excel 2003 and XP with the free Microsoft Office Compatibility Pack .

+7
source share

Take a look at NPOI:

http://www.codeplex.com/npoi

This is also pretty well described in other sections of SO:

https://stackoverflow.com/search?q=create+excel+.net

+2
source share

This is difficult to do because Microsoft recommends using the Office engine, which works great on the desktop but is useless for the Internet.

The binary .xls file format is decent, which is why Microsoft introduced the OpenXML .xlsx files in Office 2007.

.xslx supposedly simple - it's just a zip container full of XML files. You can open it with System.IO.Packaging and edit it with System.Xml . There is even a compatibility pack for older versions of the office.

Unfortunately, this is simply not easy - the .xslx format .xslx terrible beyond words .

It looks like they took the 16-bit optimized binary .xls format (originally developed for Windows 3.1) and serialized it instead of XML instead of XML. Then they added really stupid changes, such as the cell comments in fact VML - a format supposedly dropped from IE5! They also added a ton of magic numbers and metadata to XML, so you cannot use any transformations on it, so you take it apart manually.

Finally, they made it a complete donkey for debugging, and we regularly find .xslx files that the compatibility package reports as corrupted (for no reason), but this latest version of Office can open normally.

There is a really good open source library for this: SpreadsheetLight . This is a very good library, but anything that requires you to dig and stretch the .xslx files yourself will be painful.

+2
source share
+1
source share

We use a kit called Aspose at work. It has a large, fully functional Cell component that works wonders for us.

0
source share

http://epplus.codeplex.com/ - Take a look at this project, its events help me a lot. I found this link at: https://stackoverflow.com/questions/170652/whats-the-best-net-library-for-parsing-and-generating-excel-spreadsheets

0
source share
0
source share

All Articles