开发者

C# output to Excel spreadsheet, using Excel 2000+

I'm writing a program that reads a text file, extracts information, and outputs it to a template Excel spreadsheet that already exists.

I've managed to do this on my computer开发者_C百科 using the Microsoft.Office.Interop.Excel reference and its related methods, and it works fine. I have Excel 2010. However the computers that this program will be used on mostly have either Excel 2000 or Excel 2003, and it won't work on them.

Does anyone know a way to make a program target all versions of Excel from 2000 upwards?

Cheers,

Greg


If your needs are simple and you don't have $900 for Aspose.Cells to throw around, you can do any of the following:

  • Use NPOI to read, inject data into, and export your template.

  • Create a basic HTML file with a table and just named it *.xls. You can save your template in Excel as HTML and replace bits and pieces to insert your data.

  • Create an XML file using Office 2002/2003 XML format, it's pretty straightforward (caveat: can't be read in Excel 2000). As above, you can save your template in XML Spreadsheet format, read it in, and do some simple stuff to inject your data.


You really need to target 2000 or under. 2010 and 2003 will open a 2000 format document whereas 2000 will not open a 2010 document. Office has a single format for 97-2000 and that's what you need to create to make everybody happy.

Interop depends on the version you have installed and I personally have dodged using interop due to its "unmanaged" nature (and it seems to love file locks).

If you want hassle free and extremely fast/powerful creation of Excel documents, you really can not do better than Aspose.Cells in my opinion.

Find it here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜