Hi
I have an issue that I have tracked down to the InsertField procedure
When I create a table with some merging, it works fine until InsertField is called elsewhere in the document generation - this causes the table to lose some of the merging previously formatted.
I have created some example code to demonstrate
// Create document and builder
Document Document = new Aspose.Words.Document();
DocumentBuilder DocumentBuilder = new DocumentBuilder(Document);
Table Table1 = DocumentBuilder.StartTable();
//********
// Row 1
//********
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.First;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.None;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(166.9));
DocumentBuilder.Font.Bold = true;
DocumentBuilder.Write("Trade Sign Off");
DocumentBuilder.Font.Bold = false;
DocumentBuilder.Write(" – All work order tasks have been completed as instructed and all documentation has been completed");
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.None;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.First;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(60));
DocumentBuilder.Write("Name:");
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.None;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.Previous;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(46.9));
DocumentBuilder.Write("");
// End Row
DocumentBuilder.EndRow();
//********
// Row 2
//********
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.Previous;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.None;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(166.9));
DocumentBuilder.Write("");
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.None;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.None;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(60));
DocumentBuilder.Write("Signature By Me:");
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.None;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.None;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(46.9));
DocumentBuilder.Write("Date:");
// End Row
DocumentBuilder.EndRow();
//********
// Row 3
//********
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.First;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.None;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(166.9));
DocumentBuilder.Font.Bold = true;
DocumentBuilder.Write("Supervisor Sign Off");
DocumentBuilder.Font.Bold = false;
DocumentBuilder.Write(" – Work Order has been completed to a satisfactory standard, regulatory W/Os have been completed and corrective W/Os have been generated for issues found.");
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.None;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.First;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(60));
DocumentBuilder.Write("Name:");
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.None;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.Previous;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(46.9));
DocumentBuilder.Write("");
// End Row
DocumentBuilder.EndRow();
//********
// Row 4
//********
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.Previous;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.None;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(166.9));
DocumentBuilder.Write("");
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.None;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.None;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(60));
DocumentBuilder.Write("Signature:");
// Create cell
DocumentBuilder.InsertCell();
DocumentBuilder.CellFormat.VerticalMerge = CellMerge.None;
DocumentBuilder.CellFormat.HorizontalMerge = CellMerge.None;
DocumentBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.MillimeterToPoint(46.9));
DocumentBuilder.Write("Date:");
// End Row
DocumentBuilder.EndRow();
// End Table
DocumentBuilder.EndTable();
DocumentBuilder.InsertField("Page");
If you take out the last line, you will have a correctly formatted table - with it in, it causes issues with the merging.
Any suggestions would be greatly appreciated!
Cheers
Adam