当前位置: 首页>>代码示例>>Java>>正文


Java TblGrid类代码示例

本文整理汇总了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);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:31,代码来源:Docx4J_例子2.java

示例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);  
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:21,代码来源:Docx4J_简单例子2.java

示例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);

  }
 
开发者ID:plutext,项目名称:docx-html-editor,代码行数:34,代码来源:RoundtripXHTMLImporter.java


注:本文中的org.docx4j.wml.TblGrid类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。