tags:

views:

674

answers:

3

I'd like to automate data entry into Excel spreadsheets. User data will exist on a web site, and when the user requests it, that data will need to be injected into an Excel spreadsheet. The complication is that the format of the Excel spreadsheet can vary significantly between users - it'll be user defined.

I've been thinking of this as a templating problem - the excel spreadsheet provides the template, and the task s to inject data into specific user defined cells within that template.

I've looked at xlwt and xlrd for python, as well as jexcelapi and POI-HSSF for Java. They seem like they could work, but given that I simply want to put values into certain cells, they seem like overkill. I'm also worried about re-writing the user's spreadsheet after processing; seems like an opportunity to introduce errors into the process.

Is there a way to tell excel to merge the data from one sheet into another? I'm thinking I could produce a simple spreadsheet that has only the data, and somehow get Excel to merge it into the user's existing spreadsheet.

Make sense? Better approaches?

A: 

You might want to look into a third party library called Aspose.Cells. It is available for Java and .Net and allows very granular control of Excel documents. The great thing about this library is that it does not use automation (which could be disasterous in a multi-threaded environment like the web).

I have not personally used Apose.Cells, but I have used Aspose.Words (for .Net) to create mail merged Word documents that contained several thousand records and images, and it worked flawlessly.

AJ
+1  A: 

WinHttpRequest (http://msdn.microsoft.com/en-us/library/aa384045(VS.85).aspx) may suit, you can use the document and so forth. Here is a snippet from the link.

Dim HttpReq As Object

' Create the WinHTTPRequest ActiveX Object.'
Set HttpReq = New WinHttpRequest

' Open an HTTP connection.'
HttpReq.Open "GET", "http://microsoft.com", False

' Send the HTTP Request.'
HttpReq.Send

' Get all response text.'
Text1.Text = HttpReq.ResponseText
Remou
+2  A: 

jXLS is maybe an option. You define an XLS file as a template and then you merge your data.

Quick overview here

http://jxls.sourceforge.net/

RealHowTo
Very interesting, looks pretty much like what I was looking for. Going to give it a try.
Parand