Programmatic mail-merge style data injection into existing Excel spreadsheets?

Tags: excel python java
By : Parand
Source: Stackoverflow.com
Question!

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?

By : Parand


Answers

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/

By : RealHowTo


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
By : Fionnuala


the first thing striking my eyes is the casing of your endpoint address. At least all other examples posted in this thread or here use different casing. Second you are not escaping the backslashes within the string. Instead of

"FormatName:DIRECT=OS:remoteMachineName\Private$\MyQueue"

try

"FormatName:Direct=OS:remoteMachineName\\private$\\MyQueue"

hth, Erich



This video can help you solving your question :)
By: admin