本文整理汇总了Java中org.docx4j.wml.TblGrid类的典型用法代码示例。如果您正苦于以下问题:Java TblGrid类的具体用法?Java TblGrid怎么用?Java TblGrid使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TblGrid类属于org.docx4j.wml包,在下文中一共展示了TblGrid类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTableGridCol
import org.docx4j.wml.TblGrid; //导入依赖的package包/类
/**
* @param tableWidthPercent
* 表格占页面宽度百分比
* @param widthPercent
* 各列百分比
*/
public void setTableGridCol(WordprocessingMLPackage wordPackage,
ObjectFactory factory, Tbl table, double tableWidthPercent,
double[] widthPercent) throws Exception {
int width = getWritableWidth(wordPackage);
int tableWidth = (int) (width * tableWidthPercent / 100);
TblGrid tblGrid = factory.createTblGrid();
for (int i = 0; i < widthPercent.length; i++) {
TblGridCol gridCol = factory.createTblGridCol();
gridCol.setW(BigInteger.valueOf((long) (tableWidth
* widthPercent[i] / 100)));
tblGrid.getGridCol().add(gridCol);
}
table.setTblGrid(tblGrid);
TblPr tblPr = table.getTblPr();
if (tblPr == null) {
tblPr = factory.createTblPr();
}
TblWidth tblWidth = new TblWidth();
tblWidth.setType("dxa");// 这一行是必须的,不自己设置宽度默认是auto
tblWidth.setW(new BigInteger(tableWidth + ""));
tblPr.setTblW(tblWidth);
table.setTblPr(tblPr);
}
示例2: setTableGridCol
import org.docx4j.wml.TblGrid; //导入依赖的package包/类
public void setTableGridCol(WordprocessingMLPackage wordPackage,ObjectFactory factory,Tbl table,double[] widthPercent) throws Exception{
int width=getWritableWidth(wordPackage);
TblGrid tblGrid = factory.createTblGrid();
for (int i = 0; i <widthPercent.length; i++) {
TblGridCol gridCol = factory.createTblGridCol();
gridCol.setW(BigInteger.valueOf((long) (width*widthPercent[i]/100)));
tblGrid.getGridCol().add(gridCol);
}
table.setTblGrid(tblGrid);
TblPr tblPr=table.getTblPr();
if(tblPr==null){
tblPr=factory.createTblPr();
}
TblWidth tblWidth=new TblWidth();
tblWidth.setType("dxa");//这一行是必须的,不自己设置宽度默认是auto
tblWidth.setW(new BigInteger(""+width));
tblPr.setTblW(tblWidth);
table.setTblPr(tblPr);
}
示例3: setupTblGrid
import org.docx4j.wml.TblGrid; //导入依赖的package包/类
@Override
protected void setupTblGrid(TableBox cssTable, Tbl tbl, TableProperties tableProperties) {
/*
* Reinstate
*
context.getWmlPackage().setUserData(id+"#Grid", table.getTblGrid());
as set by SessionAwareAbstractTableWriter
*/
String id = cssTable.getElement().getAttribute("id");
if (id==null ) {
log.debug("no id on table " );
} else {
log.debug("processing table with id " + id);
Object o = wordMLPackage.getUserData(id+"#Grid");
if (o==null) {
log.debug("no #Grid UserData on table with id " + id);
} else {
tbl.setTblGrid((TblGrid)o);
return;
}
}
super.setupTblGrid( cssTable, tbl, tableProperties);
}