I found something weird:
I try to align three columns, but the last column cannot be align, it is always left. Other columns- first and second works properly:
for (int i = 0; i < titles.Length; i++)
{
bool rancamaya2 = true;
var mycell = builder.InsertCell();
color = Color.FromArgb(217, 217, 217);
mycell.CellFormat.Borders.Top.Color = color;
mycell.CellFormat.Borders.Bottom.Color = color;
mycell.CellFormat.Borders.Left.Color = color;
mycell.CellFormat.Borders.Right.Color = color;
if (rancamaya2)
{
if (i == 0)
{
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
builder.Write(titles[i] + "-08");
}
else if (i == 1)
{
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
builder.Write(titles[i] + "-09");
}
else
{
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right; // No Effect, no work
builder.Write(titles[i] + "-10");
}
}
}
and after this loop there is a statement:
builder.ParagraphFormat.ClearFormatting();
if i take out it, the column three works correctly, but the TOC changes to include bullets.
I tried from yesterday with many combinations, with no luck.
If it is required to clear paragraph formatting for the cell, do this just after inserting the new cell. If you call builder.ParagraphFormat.ClearFormatting(); before starting a new cell, the current document builder’s paragraph format will be cleared.
@ibox You call builder.ParagraphFormat.ClearFormatting(); after ending the row, but before starting a new cell. So DocumentBuilder’s cursor is still in the last cell of the finished row. That is why paragraph format of the last cell in the row is cleared. This is an expected behavior.
It works by putting that ClearFormatting statement after every Insert Statement.
if i miss the Clear Formatting,
why the TOC add many entries - bullets, etc?