Free Support Forum - aspose.com

Aspose inserts a unwanted tab in a table cell

Hi

I am writing a application for a client that merges several documents, and inserts a table into the document at a bookmark.

My problem is that when building the table, Aspose puts a tab in front of the text when I do a DocumentBuilder.Write call. This causes problems with the formatting of the document.

Can you please tell me if there I'm doing anything wrong, or if there's a workaround.

Here is my code, and attached is a document created with the code. The section that gives the problem is 6.0:

Private Sub InsertBudgetIntoDoc(ByVal Doc As Aspose.Words.Document, ByVal BookmarkName As String)

Dim builder As New Aspose.Words.DocumentBuilder(Doc)

Dim DBConnectionString As String = ""

DBConnectionString = ConfigurationManager.ConnectionStrings("SANERI_K2_AdminConnectionString").ConnectionString

Dim db As New CEFDBUtility.ChangeTable(DBConnectionString)

Dim dt As Data.DataTable = db.SelectBudget(txtProjectTitle.Text)

Dim Count As Integer = 1

builder.MoveToBookmark(BookmarkName, True, False)

builder.StartTable()

builder.CellFormat.Borders.Color = Drawing.Color.Black

builder.CellFormat.Borders.LineWidth = 1

builder.InsertCell()

builder.CellFormat.Width = 1000

' Apply formatting to the current cell

builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center

builder.Font.Bold = True

builder.Font.Size = 12

' Output cell content

builder.Write("Step")

' Insert a cell

builder.InsertCell()

builder.CellFormat.Width = 127.84252

' Output cell content

builder.Write("Timing")

builder.InsertCell()

builder.CellFormat.Width = 200

' Output cell content

builder.Write("Budget")

builder.EndRow()

builder.Font.Bold = False

builder.Font.Size = 10

Dim Total As Double = 0.0

'builder.ListFormat.ApplyNumberDefault()

For Each dr As Data.DataRow In dt.Rows

Dim TaskName As String = dr("TaskName")

Dim StartDate As DateTime = dr("TaskStartDate")

Dim EndDate As DateTime = dr("TaskFinishDate")

Dim TaskCost As Double = dr("TaskCost")

Total = Total + TaskCost

' Insert a cell

builder.InsertCell()

builder.CellFormat.Width = 1000

' Apply formatting to the current cell

builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left

' Output cell content

builder.Write(Count & " " & TaskName.Trim())

' Insert a cell

builder.InsertCell()

builder.CellFormat.Width = 127.84252

builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center

' Output cell content

builder.Write(StartDate.ToString("MMMyyyy") & " - " & EndDate.ToString("MMMyyyy"))

' Insert a cell

builder.InsertCell()

builder.CellFormat.Width = 200

builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left

' Output cell content

builder.Write("R " & Format(TaskCost, "### ### ##0.00"))

' End current row

builder.EndRow()

Count = Count + 1

Next

builder.InsertCell()

builder.CellFormat.Width = 1000

' Apply formatting to the current cell

builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left

builder.Font.Bold = True

builder.Font.Size = 12

' Output cell content

builder.Write("Total")

' Insert a cell

builder.InsertCell()

builder.CellFormat.Width = 127.84252

' Output cell content

'builder.Writeln("Timing")

builder.InsertCell()

builder.CellFormat.Width = 200

' Output cell content

builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Right

builder.Write("R " & Format(Total, "### ### ##0.00"))

builder.EndRow()

End Sub

Hi

Thanks for your inquiry. Maybe try using this

builder.MoveToBookmark(BookmarkName, True, True)

And this snippet to clear formatting.

builder.CellFormat.ClearFormatting()

builder.RowFormat.ClearFormatting()

builder.ParagraphFormat.ClearFormatting()

Also you can attach you input document for testing.

Hope this could help you.

Best regards.