手册表格列宽修正
This commit is contained in:
parent
2a9f325f74
commit
1a8848a390
Binary file not shown.
@ -437,16 +437,14 @@ public class OutputWordUtil {
|
||||
//添加表格
|
||||
Table table = section.addTable(true);
|
||||
table.resetCells(data.length + 1, header.length);
|
||||
|
||||
table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Window);
|
||||
TableRow row = table.getRows().get(0);
|
||||
row.isHeader(true);
|
||||
row.setHeightType(TableRowHeightType.Auto);
|
||||
|
||||
|
||||
row.setHeightType(TableRowHeightType.Exactly);
|
||||
for (int i = 0; i < header.length; i++) {
|
||||
row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
|
||||
//设置固定列宽
|
||||
if(i==0){
|
||||
/*if(i==0){
|
||||
row.getCells().get(0).setWidth(40);
|
||||
}else if(i==1){
|
||||
row.getCells().get(1).setWidth(60);
|
||||
@ -462,7 +460,7 @@ public class OutputWordUtil {
|
||||
row.getCells().get(6).setWidth(50);
|
||||
}else if(i==7){
|
||||
row.getCells().get(7).setWidth(80);
|
||||
}
|
||||
}*/
|
||||
Paragraph p = row.getCells().get(i).addParagraph();
|
||||
|
||||
p.getFormat().setHorizontalAlignment(Center);
|
||||
@ -482,13 +480,13 @@ public class OutputWordUtil {
|
||||
TableRow dataRow = table.getRows().get(r + 1);
|
||||
|
||||
dataRow.setHeight(25);
|
||||
dataRow.setHeightType(TableRowHeightType.Auto);
|
||||
dataRow.setHeightType(TableRowHeightType.Exactly);
|
||||
dataRow.getRowFormat().setBackColor(Color.white);
|
||||
|
||||
for (int c = 0; c < data[r].length; c++) {
|
||||
dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
|
||||
//设置固定列宽
|
||||
if(c==0){
|
||||
/* if(c==0){
|
||||
dataRow.getCells().get(0).setWidth(40);
|
||||
}else if(c==1){
|
||||
dataRow.getCells().get(1).setWidth(60);
|
||||
@ -504,7 +502,7 @@ public class OutputWordUtil {
|
||||
dataRow.getCells().get(6).setWidth(50);
|
||||
}else if(c==7){
|
||||
dataRow.getCells().get(7).setWidth(80);
|
||||
}
|
||||
}*/
|
||||
|
||||
//dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
|
||||
|
||||
@ -736,34 +734,39 @@ public class OutputWordUtil {
|
||||
//添加表格
|
||||
Table table = section.addTable(true);
|
||||
table.resetCells(data.length + 1, header.length);
|
||||
table.getTableFormat().isAutoResized(true);
|
||||
|
||||
table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Window);
|
||||
|
||||
TableRow row = table.getRows().get(0);
|
||||
row.isHeader(true);
|
||||
row.setHeight(20);
|
||||
row.setHeightType(TableRowHeightType.Auto);
|
||||
row.setHeightType(TableRowHeightType.Exactly);
|
||||
for (int i = 0; i < header.length; i++) {
|
||||
row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
|
||||
//设置固定列宽
|
||||
row.getCells().get(0).setWidth(150);
|
||||
row.getCells().get(1).setWidth(500);
|
||||
//row.getCells().get(0).setWidth(50);
|
||||
//row.getCells().get(1).setWidth(150);
|
||||
Paragraph p = row.getCells().get(i).addParagraph();
|
||||
p.getFormat().setHorizontalAlignment(Center);
|
||||
TextRange txtRange = p.appendText(header[i]);
|
||||
txtRange.getCharacterFormat().setBold(true);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//将数据添加到其余行
|
||||
for (int r = 0; r < data.length; r++) {
|
||||
TableRow dataRow = table.getRows().get(r + 1);
|
||||
dataRow.setHeight(25);
|
||||
dataRow.setHeightType(TableRowHeightType.Auto);
|
||||
dataRow.setHeightType(TableRowHeightType.Exactly);
|
||||
dataRow.getRowFormat().setBackColor(Color.white);
|
||||
for (int c = 0; c < data[r].length; c++) {
|
||||
dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
|
||||
//设置固定列宽
|
||||
dataRow.getCells().get(0).setWidth(150);
|
||||
dataRow.getCells().get(1).setWidth(500);
|
||||
//dataRow.getCells().get(0).setWidth(50);
|
||||
//dataRow.getCells().get(1).setWidth(150);
|
||||
//dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
|
||||
|
||||
TextRange text =dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
|
||||
@ -772,6 +775,8 @@ public class OutputWordUtil {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Paragraph paragraph_blank = section.addParagraph();
|
||||
|
||||
}
|
||||
@ -852,12 +857,12 @@ public class OutputWordUtil {
|
||||
TableRow row = table.getRows().get(0);
|
||||
row.isHeader(true);
|
||||
row.setHeight(20);
|
||||
row.setHeightType(TableRowHeightType.Auto);
|
||||
row.setHeightType(TableRowHeightType.Exactly);
|
||||
for (int i = 0; i < header.length; i++) {
|
||||
row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
|
||||
//设置固定列宽
|
||||
row.getCells().get(0).setWidth(150);
|
||||
row.getCells().get(1).setWidth(500);
|
||||
//row.getCells().get(0).setWidth(150);
|
||||
//row.getCells().get(1).setWidth(500);
|
||||
Paragraph p = row.getCells().get(i).addParagraph();
|
||||
p.getFormat().setHorizontalAlignment(Center);
|
||||
TextRange txtRange = p.appendText(header[i]);
|
||||
@ -869,13 +874,13 @@ public class OutputWordUtil {
|
||||
for (int r = 0; r < data.length; r++) {
|
||||
TableRow dataRow = table.getRows().get(r + 1);
|
||||
dataRow.setHeight(25);
|
||||
dataRow.setHeightType(TableRowHeightType.Auto);
|
||||
dataRow.setHeightType(TableRowHeightType.Exactly);
|
||||
dataRow.getRowFormat().setBackColor(Color.white);
|
||||
for (int c = 0; c < data[r].length; c++) {
|
||||
dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
|
||||
//设置固定列宽
|
||||
dataRow.getCells().get(0).setWidth(150);
|
||||
dataRow.getCells().get(1).setWidth(500);
|
||||
//dataRow.getCells().get(0).setWidth(150);
|
||||
//dataRow.getCells().get(1).setWidth(500);
|
||||
//dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
|
||||
TextRange text =dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
|
||||
text.getCharacterFormat().setFontName("宋体");
|
||||
@ -938,6 +943,7 @@ public class OutputWordUtil {
|
||||
Table table = section.addTable(true);
|
||||
table.resetCells(data.length + 1, header.length);
|
||||
|
||||
table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Window);
|
||||
|
||||
TableRow row = table.getRows().get(0);
|
||||
row.isHeader(true);
|
||||
@ -946,8 +952,8 @@ public class OutputWordUtil {
|
||||
for (int i = 0; i < header.length; i++) {
|
||||
row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
|
||||
//设置固定列宽
|
||||
row.getCells().get(0).setWidth(150);
|
||||
row.getCells().get(1).setWidth(500);
|
||||
//row.getCells().get(0).setWidth(150);
|
||||
//row.getCells().get(1).setWidth(500);
|
||||
Paragraph p = row.getCells().get(i).addParagraph();
|
||||
p.getFormat().setHorizontalAlignment(Center);
|
||||
TextRange txtRange = p.appendText(header[i]);
|
||||
@ -963,8 +969,8 @@ public class OutputWordUtil {
|
||||
for (int c = 0; c < data[r].length; c++) {
|
||||
dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
|
||||
//设置固定列宽
|
||||
dataRow.getCells().get(0).setWidth(150);
|
||||
dataRow.getCells().get(1).setWidth(500);
|
||||
//dataRow.getCells().get(0).setWidth(150);
|
||||
//dataRow.getCells().get(1).setWidth(500);
|
||||
//dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
|
||||
TextRange text =dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
|
||||
text.getCharacterFormat().setFontName("宋体");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user