Yes - you can use Excel.Interop - link to it from your C # program by adding a link to Microsoft.Office.Interop.Excel (version 13, I think for Excel 2010) on the .Net tab in VS add the link.
FYI: It is not recommended to run daemons on the server using Interop: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2 , however if it is a short program launched by the user and you control it should be okay.
If you want your clients to run the program, they will need to install the primary investment assembly (PIA), if they have not already installed an office, they can be found here:
XP: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=C41BD61E-3060-4F71-A6B4-01FEBA508E52
2003: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=3C9A983A-AC14-4125-8BA0-D36D67E0F4AD
2007: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=59DAEBAA-BED4-4282-A28C-B864D8BFA513
2010: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=938fe8ad-583b-4bd7-a345-23250dc15855
I use Office11 on my x64 Vista machine, so I don't think x64 will be a problem.
Be careful, the documentation is terrible! There are about 10 different versions of help, documentation there. I recommend:
Acquaintance with:
- Application
- Workbook
- Worksheet
- Range
objects. You can read the data in List <List <string →> (in this case all your cells would have to be formatted as text) or something in memory, then you no longer have to deal with Interop and its v. fast on. A method is always used from C # (some documentation mistakenly states that you cannot use the methods that they use for internal use), for example: Range.get_Values ("A1"), unlike: Range.Cells;
A good place to start is here: http://dotnetperls.com/excel-interop
The official documentation is here: http://msdn.microsoft.com/en-us/library/bb726434(v=office.12).aspx , but it contains a load of marketing waffles until you get to the Interop library, part of which is a decade .
And be careful: the Excel index is based on 1, i.e. the first element in the returned 2D array starts with my2DArray [1,1]!
markmnl
source share