now i need to insert some data from the sqlserver into a word,i know how to use bookmark and the office interop api do that but it's slow to call the word process do that and it's coupling between the bookmark define and the code , is it possible to do this without word process start?if not are there any template engine to do this?
views:
2091answers:
5You may want to look at a custom document writer, rather than using the COM Wrapped API from Microsoft. I have heard good things about OfficeWriter. It's not free, but speed never is.
It doesn't require Word on the server.
thanks for your help,but the company is not in my county and paypal is not valid here,is it possible to operator a doc format file in stream?what about the ServerDocument class?
Not sure if this will help any, but if it is tabular data from SQL Server you need it might be possible to pull it into Excel first (through an embedded query) then embed the Excel table in the Word doc (OLE).
Sounds pretty clugy, but I've done worse. :-)
Ron
I don't have an exact answer for what you wish to do. However you may wish to think about building the whole document on your server.
MS Excel 97 onwards supports creating a simple XML or HTML (with tables) file and just calling the file something-uniqueid.xls
It's possible that MS Word also does something similar. Take any basic HTML file (use <h1> <h2> <u>
tags for a start) and change the name to something.doc
See if Word will open it by double clicking it.
If this works you can serve up the whole document as a html file but tell the client that it is called something-unique-id#.doc
For this to work from a web server you will need to set the HTTP headers Content-type: application/msword
and Content-disposition: Attachment; filename=something-unique-id.doc
Please check the MIME type for msword.. i'm not sure if that is correct.
Last but not least to be 100% sure try using URLs with the very last GET variable set to .doc
this means your URL should look like /listing.asp?var1=abc&var2=def&output=.doc
This was necessary nine years ago to give 100% coverage of the browsers. You'd have to test whether it was still required.