tags:

views:

64

answers:

3

I want to create a service which will insert provided data into spreadsheet fields and get results from other spreadsheet fields after they are recalculated and it should support multiple parallel executions. Is this possible at all and maybe somebody can give a link with some tutorial I can begin learning from?

A: 

You can use Office automation using Microsoft.Office.Interop.Excel as described here:

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel%28office.11%29.aspx

It's fairly easy to connect to Excel and make it do stuff but it can be a little unstable and a little more difficult to close it down properly afterwards.

And here's a sample:

http://support.microsoft.com/kb/302084

ho1
A: 

I have created such a service in the past using smartxls It allows you to open an existing spreadsheet, fill in some values and read the result. It's not free however.

Sample code:

WorkBook book = new WorkBook();
string path = "c:\sheet.xls";
//Open an existing spreadsheet which will be used as a template for generating the new spreadsheet.
//After opening, the workbook object represents the complete in-memory object model of the template spreadsheet.
book.read(path);

book.Sheet = 0; //base
book.setText(15, 4, "man"); 
book.setEntry(17, 4, DateTime.Now);
book.recalc();
  • disclaimer: I am not the author or in any way affiliated with SmartXls
edosoft
A: 

I don't believe Microsoft.Office.Interop.Excel supports parallel processing.

Your best bet is to get a third party process. I've used NPoi with good results, but a lot of it will depend on which versions of Excel you want to support.

http://npoi.codeplex.com/

ETA: Tutorial here http://www.leniel.net/2009/07/creating-excel-spreadsheets-xls-xlsx-c.html

bryanjonker