如何在相同高度的textFrame中获取两个表
How to get two tables within a textFrame at the same Height
我在 textFrame 中创建了两个 tables,因为有人告诉我这可能是让两个 tables 在相同高度彼此交叉的最佳方式。当我为右边的 table 填写我的数据和 headers 时,它不会延伸到与左边的 table 相同高度的底部。即使我添加了更多的 AddParagraphs(),右侧 table 大麦的底部也超过了左侧 table 的底部边界,因此使 table 的高度不均匀。有没有修复或不同的方法来做到这一点?我希望右侧 table 上写着 "ADV Integrity" 的地方与 table.
左侧的高度相同
我的代码:
//textFrame for Invoice info
TextFrame billFrame = section.AddTextFrame();
billFrame.Height = "5.0cm";
billFrame.Width = "6.0cm";
billFrame.RelativeHorizontal = RelativeHorizontal.Margin;
billFrame.Top = "7.5cm";
billFrame.MarginRight = "10.0cm";
billFrame.RelativeVertical = RelativeVertical.Page;
billFrame.Left = ShapePosition.Left;
//putting table into the Invoice textFrame
Table table = billFrame.AddTable();
table.Borders.Width = 0.75;
Column column = table.AddColumn(Unit.FromCentimeter(7));
column.Format.Alignment = ParagraphAlignment.Left;
//define headers of "Bill To" table
Row row = table.AddRow();
row.HeadingFormat = true;
Cell cell = row.Cells[0];
row.Shading.Color = Colors.LightGray;
cell.AddParagraph("Bill To:");
cell.Format.Font.Bold = true;
//showing data inside Bill table
row = table.AddRow();
cell = row.Cells[0];
cell.AddParagraph("ADV Integrity");
cell.AddParagraph("Attn: Wendy Courtright");
cell.AddParagraph("P.O. Box 1449");
cell.AddParagraph("Waller, TX 77484");
cell.AddParagraph("United States");
//textFrame for Invoice info
TextFrame invoiceFrame = section.AddTextFrame();
invoiceFrame.Height = "5.0cm";
invoiceFrame.Width = "6.0cm";
invoiceFrame.Left = ShapePosition.Right;
//adding table inside Invoice textFrame
table = invoiceFrame.AddTable();
table.Borders.Width = 0.75;
column = table.AddColumn(Unit.FromCentimeter(3.5));
column.Format.Alignment = ParagraphAlignment.Left;
column = table.AddColumn(Unit.FromCentimeter(3.5));
column.Format.Alignment = ParagraphAlignment.Left;
//headers for Invoice table
row = table.AddRow();
row.HeadingFormat = true;
cell = row.Cells[0];
row.Shading.Color = Colors.LightGray;
cell.AddParagraph("Date");
cell.Format.Font.Bold = true;
cell = row.Cells[1];
cell.AddParagraph("Invoice");
cell.Format.Font.Bold = true;
//defining rows and data inside Invoice table
row = table.AddRow();
cell = row.Cells[0];
cell.AddParagraph("04/30/2020");
cell = row.Cells[1];
cell.AddParagraph("2000498");
row = table.AddRow();
cell = row.Cells[0];
row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
row.Cells[0].Format.Font.Bold = true;
row.Cells[0].Shading.Color = Colors.LightGray;
row.Cells[0].MergeRight = 1;
cell.AddParagraph("Account");
row = table.AddRow();
cell = row.Cells[0];
row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
row.Cells[0].MergeRight = 1;
cell.AddParagraph("ADV Integrity");
目前的样子:
我会创建一个 table,中间有一个不可见的列。单身table,一个身高,问题解决。如果您想要一个单元格作为地址,您可以使用 MergeDown
。
对于两个 table,您可以设置行的高度以确保两个 table 具有相同的高度。如果单元格的内容突然不适合 table.
的高度,这可能会导致新问题
我在 textFrame 中创建了两个 tables,因为有人告诉我这可能是让两个 tables 在相同高度彼此交叉的最佳方式。当我为右边的 table 填写我的数据和 headers 时,它不会延伸到与左边的 table 相同高度的底部。即使我添加了更多的 AddParagraphs(),右侧 table 大麦的底部也超过了左侧 table 的底部边界,因此使 table 的高度不均匀。有没有修复或不同的方法来做到这一点?我希望右侧 table 上写着 "ADV Integrity" 的地方与 table.
左侧的高度相同我的代码:
//textFrame for Invoice info
TextFrame billFrame = section.AddTextFrame();
billFrame.Height = "5.0cm";
billFrame.Width = "6.0cm";
billFrame.RelativeHorizontal = RelativeHorizontal.Margin;
billFrame.Top = "7.5cm";
billFrame.MarginRight = "10.0cm";
billFrame.RelativeVertical = RelativeVertical.Page;
billFrame.Left = ShapePosition.Left;
//putting table into the Invoice textFrame
Table table = billFrame.AddTable();
table.Borders.Width = 0.75;
Column column = table.AddColumn(Unit.FromCentimeter(7));
column.Format.Alignment = ParagraphAlignment.Left;
//define headers of "Bill To" table
Row row = table.AddRow();
row.HeadingFormat = true;
Cell cell = row.Cells[0];
row.Shading.Color = Colors.LightGray;
cell.AddParagraph("Bill To:");
cell.Format.Font.Bold = true;
//showing data inside Bill table
row = table.AddRow();
cell = row.Cells[0];
cell.AddParagraph("ADV Integrity");
cell.AddParagraph("Attn: Wendy Courtright");
cell.AddParagraph("P.O. Box 1449");
cell.AddParagraph("Waller, TX 77484");
cell.AddParagraph("United States");
//textFrame for Invoice info
TextFrame invoiceFrame = section.AddTextFrame();
invoiceFrame.Height = "5.0cm";
invoiceFrame.Width = "6.0cm";
invoiceFrame.Left = ShapePosition.Right;
//adding table inside Invoice textFrame
table = invoiceFrame.AddTable();
table.Borders.Width = 0.75;
column = table.AddColumn(Unit.FromCentimeter(3.5));
column.Format.Alignment = ParagraphAlignment.Left;
column = table.AddColumn(Unit.FromCentimeter(3.5));
column.Format.Alignment = ParagraphAlignment.Left;
//headers for Invoice table
row = table.AddRow();
row.HeadingFormat = true;
cell = row.Cells[0];
row.Shading.Color = Colors.LightGray;
cell.AddParagraph("Date");
cell.Format.Font.Bold = true;
cell = row.Cells[1];
cell.AddParagraph("Invoice");
cell.Format.Font.Bold = true;
//defining rows and data inside Invoice table
row = table.AddRow();
cell = row.Cells[0];
cell.AddParagraph("04/30/2020");
cell = row.Cells[1];
cell.AddParagraph("2000498");
row = table.AddRow();
cell = row.Cells[0];
row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
row.Cells[0].Format.Font.Bold = true;
row.Cells[0].Shading.Color = Colors.LightGray;
row.Cells[0].MergeRight = 1;
cell.AddParagraph("Account");
row = table.AddRow();
cell = row.Cells[0];
row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
row.Cells[0].MergeRight = 1;
cell.AddParagraph("ADV Integrity");
目前的样子:
我会创建一个 table,中间有一个不可见的列。单身table,一个身高,问题解决。如果您想要一个单元格作为地址,您可以使用 MergeDown
。
对于两个 table,您可以设置行的高度以确保两个 table 具有相同的高度。如果单元格的内容突然不适合 table.
的高度,这可能会导致新问题