Word Automation

G

Guest

Hi,

I have a question about generating a word document from a template document
in a web control / web part. I'am using now the aspose.word dll's but for
this solution we have to pay a lot of money.

I searched the internet for a couple of days now, for a good example how to
render a word document based on a template and updating mergefields in that
new generated document. Does anybody known a good solution for this? Of some
url's .....I found only 1 example about a windows forms.

I want to use c#, but an example with vb is also good.
 
L

Lucas Tam

I searched the internet for a couple of days now, for a good example
how to render a word document based on a template and updating
mergefields in that new generated document. Does anybody known a good
solution for this? Of some url's .....I found only 1 example about a
windows forms.

You can use Microsoft Office Interops... they're free, but not recommended
for IIS use.
 
F

Ford

use Microsoft Office Web Components 9.0 COM
eg for Excel:
Imports System.Data.OleDb
Imports OWC

<!--StartFragment-->Dim xlsheet As New SpreadsheetClass()
cnn.Open()
Dim reader As OleDbDataReader = Me.sql.ExecuteReader()
Dim numbercols As Integer = reader.FieldCount
Dim row As Integer = 2
Dim i As Integer = 0

For i = 0 To numbercols - 1
xlsheet.ActiveSheet.Cells(1, i + 1) = reader.GetName(i).ToString()
Next

While (reader.Read())
For i = 0 To numbercols - 1
xlsheet.ActiveSheet.Cells(row, i + 1) =
reader.GetValue(i).ToString()
Next
row = row + 1
End While
reader.Close()
cnn.Close()
Try
xlsheet.ActiveSheet.Export(Server.MapPath(".") + "\Images\" +
Me.xlfile.Text,_
OWC.SheetExportActionEnum.ssExportActionNone)
Catch e As System.Runtime.InteropServices.COMException
Response.Write("error£º" + e.Message)
End Try
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top