Home » excel » .net – Getting data from C# to Excel 03/07

.net – Getting data from C# to Excel 03/07

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have files with tons of real time data that I process with an C# application. After processing the data it is presented in Excel using a specific template.

This is solved using Interop today. I must say I don’t completely gasp the whole Interop situation. Do I have to manually install the Interop functionality on each end user terminal somehow? How does it handle the mix of 2003/2007 versions?

How to&Answers:

If you know the structure of your Excel document (and presuming you don’t want and kind of complex macros/ functions/ etc within the Excel document) you can generate XML using the Excel XML format. I’m not referring to OpenXML, I’m referring to the XML format used by Excel prior to 2007.

I cover how to do it here: http://www.aaron-powell.com//blog/september-2008/linq-to-xml-to-excel.aspx

The problem with Interop is that it isn’t really designed to hard core document generation. If you try and do a lot of document processing you can run into locks

Answer:

I’ve always used FileHelpers. You shouldn’t have to do anything with the Excel installation.

Answer:

We use SyncFusion which works pretty well. Pretty easy to use too.

Answer:

Not sure what you are getting at, but you can read and write Excel files via ADO.NET. This is not interop, nor is it XML file processing. Example.

Answer:

If you can use Excel 2007 format use Office Open XML SDK, you can find samples there.
I used for some developments and is a bit tricky at the beginning if you have to create the file from scratch, but if you have a template as in your case, then it is easier. It is fast and don’t need to have excel installed in the server.