i want to create table with custom width setting, use aspose to test two case , all of case has four columns.
first scenario:
10%, 15%, 55%, 20%
second scenario:
10%, 15%, auto, 20%
in imaging, this two scenario will going to the same result. but is not, below picture show the real result.
table width
below is my test code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
ADoc.Tables.Table tbl = builder.StartTable();
ADoc.Tables.Cell versionCell = builder.InsertCell();
builder.CellFormat.PreferredWidth = ADoc.Tables.PreferredWidth.FromPercent(10); //10%
builder.Write("版本");
ADoc.Tables.Cell authorCell = builder.InsertCell();
builder.CellFormat.PreferredWidth = ADoc.Tables.PreferredWidth.FromPercent(15); //15%
builder.Write("作者");
ADoc.Tables.Cell descCell = builder.InsertCell();
builder.CellFormat.PreferredWidth = ADoc.Tables.PreferredWidth.Auto;
// builder.CellFormat.PreferredWidth = ADoc.Tables.PreferredWidth.FromPercent(55); //55%
builder.Write("更新说明");
ADoc.Tables.Cell datetimeCell = builder.InsertCell();
builder.CellFormat.PreferredWidth = ADoc.Tables.PreferredWidth.FromPercent(20); //15%
builder.Write("时间");
builder.EndRow();
tbl.PreferredWidth = ADoc.Tables.PreferredWidth.FromPercent(100);
for (int i = 0; i < 4; i++) { // insert a blank row
builder.InsertCell();
}
builder.EndRow();
builder.EndTable();
// tbl.StyleIdentifier = ADoc.StyleIdentifier.TableColumns5;
doc.Save(@"C:\Users\CHN\Desktop\testDoc\" + "out.docx");
the attachment is my standalone testing code.
in use 14.2