views:

2091

answers:

5

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?

A: 

You 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.

http://officewriter.softartisans.com/officewriter-59.aspx

Jason Stevenson
A: 

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?

sdhjl2000
A: 

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

Ron Savage
stream or file?can you tell me how to solve the format problem?by the way i really don't like to save the stream to disk and then manipulate the file, it's slow?
sdhjl2000
A: 

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.

Mark Nold
thanks for you answer,but i have to use other function of the doc tyoe file.what i need is to convert the doc binary stream to a structure format then do somthing with it,if the client use office2007 it's easy to do this with openxml,but i need to do this with word2003,sorry for my poor english.
sdhjl2000
A: 

Have a look at Aspose.Words, the reporting feature.

romeok