I'm experiencing problems with generated tables in code. The width of the table stays the same after a while. Below is the code to generate a table.
builder.CellFormat.ClearFormatting()
' Header rij met vette koppen en onderlijnd
builder.Font.Bold = True
builder.CellFormat.Borders(Aspose.Words.BorderType.Bottom).LineStyle = LineStyle.Single
builder.StartTable()
builder.InsertCell()
builder.CellFormat.Width = 170.0
builder.Write("Naam")
builder.InsertCell()
builder.CellFormat.Width = 40.0
builder.Write("Keten")
builder.InsertCell()
builder.CellFormat.Width = 40.0
builder.Write("FPZ")
builder.InsertCell()
builder.CellFormat.Width = 85.0
builder.Write("Marktaandeel")
builder.InsertCell()
builder.CellFormat.Width = 105.0
builder.Write("Marktontwikkeling")
builder.EndRow()
' Overige regels gewoon
builder.Font.Bold = False
builder.CellFormat.ClearFormatting()
builder.CellFormat.Borders(Aspose.Words.BorderType.Bottom).ClearFormatting()
For Each S1_ConcurrentieApotheek In colConcurentieApotheken
For x = 0 To 4
builder.InsertCell()
builder.CellFormat.ClearFormatting()
Select Case x
Case 0
builder.CellFormat.Width = 170.0
builder.Write(S1_ConcurrentieApotheek.Naam)
Case 1
builder.CellFormat.Width = 40.0
builder.Write(S1_ConcurrentieApotheek.Keten)
Case 2
builder.CellFormat.Width = 40.0
builder.Write(S1_ConcurrentieApotheek.Fpz)
Case 3
builder.CellFormat.Width = 85.0
builder.Write(S1_ConcurrentieApotheek.Omvang)
Case 4
builder.CellFormat.Width = 105.0
builder.Write(S1_ConcurrentieApotheek.Ontwikkeling)
End Select
Next
builder.EndRow()
builder.CellFormat.ClearFormatting()
Next
builder.EndTable()
When running this code the first time it shows perfectly. A second time it doesn't when filling another table with exactly the same formatting code but different data. And suprisingly a third time it works fine again. After some tables the total width of the table will always be the same. This occurs for all instances after tables not generated in code but in MS Word.
I just cannot figure it out what is going wrong. Any suggestions are greatly appreciated.
Regards,
Willem Jan Kortleve