Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Nov 22, 2013 1:53 am

Hello there
We have inherited an application that is using Spire to convert Word documents (as templates) for our Invoices. The templates have bookmarks to control where the data is to be replaced from the database.

If the Word template has a colour theme and images in the header how do we keep those themes and images in the final document as these seem to disappear after the data has been inserted. The code is saving the final document as a PDF to be sent via email.

The code below is how the application is currently inserting the data...

Dim ResultSet As DataSet = clsDoc.DOCGEN_INVOICE_DS_InvoiceDetailInGroup(UserID, InvoiceNumber)
If ResultSet.Tables.Count > 0 Then

Dim _Code As String = String.Empty
Dim TotRow As Integer = ResultSet.Tables(0).Rows.Count
Dim RowCounter As Integer = 0
Dim CountLabel As String = String.Empty

Dim bn As New BookmarksNavigator(myDoc)
bn.MoveToBookmark(sBM, False, True)

' Dim _Section As Section = myDoc.AddSection
' Dim _MyTable As Spire.Doc.Table = _Section.AddTable

Dim _MyTable As Table = New Table(myDoc)
_MyTable.ResetCells(TotRow + 1, 7)

For Each row As TableRow In _MyTable.Rows
row.RowFormat.Borders.BorderType = BorderStyle.None

row.Cells(0).Width = "60"
row.Cells(0).CellFormat.Borders.BorderType = BorderStyle.None
row.Cells(0).AddParagraph.Format.HorizontalAlignment = HorizontalAlignment.Left

row.Cells(1).Width = "215"
row.Cells(1).AddParagraph.Format.HorizontalAlignment = HorizontalAlignment.Left
row.Cells(1).CellFormat.Borders.BorderType = BorderStyle.None

row.Cells(2).Width = "55"
row.Cells(2).AddParagraph.Format.HorizontalAlignment = HorizontalAlignment.Left
row.Cells(2).CellFormat.Borders.BorderType = BorderStyle.None

row.Cells(3).Width = "35"
row.Cells(3).AddParagraph.Format.HorizontalAlignment = HorizontalAlignment.Left
row.Cells(3).CellFormat.Borders.BorderType = BorderStyle.None

row.Cells(4).Width = "55"
row.Cells(4).AddParagraph.Format.HorizontalAlignment = HorizontalAlignment.Right
row.Cells(4).CellFormat.Borders.BorderType = BorderStyle.None

row.Cells(5).Width = "40"
row.Cells(5).AddParagraph.Format.HorizontalAlignment = HorizontalAlignment.Right
row.Cells(5).CellFormat.Borders.BorderType = BorderStyle.None

row.Cells(6).Width = "60"
row.Cells(6).AddParagraph.Format.HorizontalAlignment = HorizontalAlignment.Right
row.Cells(6).CellFormat.Borders.BorderType = BorderStyle.None

Next

_MyTable.Rows(RowCounter).Cells(0).AddParagraph.AppendText("Date").CharacterFormat.Bold = True
_MyTable.Rows(RowCounter).Cells(1).AddParagraph.AppendText("Activity").CharacterFormat.Bold = True
_MyTable.Rows(RowCounter).Cells(2).AddParagraph.AppendText("Code").CharacterFormat.Bold = True
_MyTable.Rows(RowCounter).Cells(3).AddParagraph.AppendText("Time").CharacterFormat.Bold = True
_MyTable.Rows(RowCounter).Cells(4).AddParagraph.AppendText("Ex GST").CharacterFormat.Bold = True
_MyTable.Rows(RowCounter).Cells(5).AddParagraph.AppendText("GST").CharacterFormat.Bold = True
_MyTable.Rows(RowCounter).Cells(6).AddParagraph.AppendText("Amount").CharacterFormat.Bold = True

RowCounter += 1

For Each row In ResultSet.Tables(0).Rows
If String.IsNullOrEmpty(_Code) Then
_Code = CStr(row("OfficialCode")).ToString
End If

Assign_Row(_MyTable.Rows(RowCounter), row("NoteDate"), row("TACInfo"), row("OfficialCode"), row("TACMinute"), _
FormatCurrency(row("Fee"), 2).ToString, _
FormatCurrency(row("GSTAmt"), 2).ToString, _
FormatCurrency(row("TotalAmt"), 2).ToString)
RowCounter += 1

If _Code <> CStr(row("OfficialCode")).ToString Then
_Code = CStr(row("OfficialCode")).ToString
End If
Next

' myDoc.Sections.Remove(_Section)
bn.InsertTable(_MyTable)
End If

apm
 
Posts: 1
Joined: Fri Nov 15, 2013 4:19 am

Fri Nov 22, 2013 3:55 am

Hello Stuart,

Thanks for your feedback.
We have done some similar test with your template and Spire.Doc4.9.42, and it works fine, please download and test Spire.Doc4.9.42(http://www.e-iceblue.com/Download/downl ... t-now.html) . If the issue still exist, could you please provide us your full test code if convenience? It would be helpful to reproduce the issue you experienced and work out the solution for you ASAP.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.Doc

cron