Merged cells and table torder

Questions and answers on how to use DOCXReadWrite
Post Reply
cniccolo
Posts: 5
Joined: Tue Nov 09, 2021 2:39 pm

Merged cells and table torder

Post by cniccolo »

Dear Lars

We are using the simplified code below to generate a table on a report. When we remove the AddBorderTop from the last block (that prints the "g") everything is fine. If we leave the line in a border is shown in cell 4. The behaviour also disappears when the MergeCells statement is removed. I searched but could not find the code part that is responsible for this. It is not critical since we have a workaround

Code: Select all

  Table := DOCX.Editor.AppendTableUI(5, 2);
  Table.TAPX.AddBorders;
  Table.TAPX.BorderLeft.Style := stbNone;
  Table.TAPX.BorderTop.Style := stbNone;
  Table.TAPX.BorderRight.Style := stbNone;
  Table.TAPX.BorderBottom.Style := stbNone;

  Table.SetWidthPercent(100);

  Table.MergeCells(1,0,2,0);

  TableCell := Table.Rows[0].Cells[1];
  TableCell.Props.AddBorders(1,$000000,stbSingle,0);
  TableCell.Paras.Last.AppendPlainText( 'b');

  TableCell := Table.Rows[0].Cells[2];
  TableCell.AddProps;
  TableCell.Props.AddBorderLeft(1,$000000,stbSingle,0);
  TableCell.Props.AddBorderTop(1,$000000,stbSingle,0);
  TableCell.Props.AddBorderBottom(1,$000000,stbSingle,0);
  TableCell.Props.AddBorderRight(0.5,$000000,stbSingle,0);
  TableCell.Paras.Last.AppendPlainText( 'c');

  TableCell := Table.Rows[1].Cells[1];
  TableCell.AddProps;
  TableCell.Props.AddBorderLeft(1,$000000,stbSingle,0);
  TableCell.Props.AddBorderTop(1,$000000,stbSingle,0);
  TableCell.Props.AddBorderRight(0.5,$000000,stbSingle,0);
  TableCell.Paras.Last.AppendPlainText( 'e');

  TableCell := Table.Rows[1].Cells[2];
  TableCell.AddProps;
  TableCell.Props.AddBorderLeft(0.5,$000000,stbSingle,0);
  TableCell.Props.AddBorderTop(1,$000000,stbSingle,0);
  TableCell.Props.AddBorderRight(0.5,$000000,stbSingle,0);
  TableCell.Paras.Last.AppendPlainText( 'f');

  TableCell := Table.Rows[1].Cells[3];
  TableCell.AddProps;
  TableCell.Props.AddBorderLeft(0.5,$000000,stbSingle,0);
  TableCell.Props.AddBorderTop(1,$000000,stbSingle,0);
  TableCell.Props.AddBorderRight(0.5,$000000,stbSingle,0);
  TableCell.Paras.Last.AppendPlainText('g');
Post Reply