本文整理汇总了Java中org.docx4j.wml.TcPrInner.GridSpan类的典型用法代码示例。如果您正苦于以下问题:Java GridSpan类的具体用法?Java GridSpan怎么用?Java GridSpan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GridSpan类属于org.docx4j.wml.TcPrInner包,在下文中一共展示了GridSpan类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTcByPosition
import org.docx4j.wml.TcPrInner.GridSpan; //导入依赖的package包/类
public Tc getTcByPosition(List<Tc> tcList, int position) {
int k = 0;
for (int i = 0, len = tcList.size(); i < len; i++) {
Tc tc = tcList.get(i);
TcPr trPr = tc.getTcPr();
if (trPr != null) {
GridSpan gridSpan = trPr.getGridSpan();
if (gridSpan != null) {
k += gridSpan.getVal().intValue() - 1;
}
}
if (k >= position) {
return tcList.get(i);
}
k++;
}
if (position < tcList.size()) {
return tcList.get(position);
}
return null;
}
示例2: getTcCellSizeWithMergeNum
import org.docx4j.wml.TcPrInner.GridSpan; //导入依赖的package包/类
/**
* @Description: 得到行的列数
*/
public int getTcCellSizeWithMergeNum(Tr tr) {
int cellSize = 1;
List<Tc> tcList = getTrAllCell(tr);
if (tcList == null || tcList.size() == 0) {
return cellSize;
}
cellSize = tcList.size();
for (Tc tc : tcList) {
TcPr tcPr = getTcPr(tc);
GridSpan gridSpan = tcPr.getGridSpan();
if (gridSpan != null) {
cellSize += gridSpan.getVal().intValue() - 1;
}
}
return cellSize;
}
示例3: getTcByPosition
import org.docx4j.wml.TcPrInner.GridSpan; //导入依赖的package包/类
/**
* 实现思路:
主要分在当前行上方插入行和在当前行下方插入行。对首尾2行特殊处理,在有跨行合并情况时,在第一行上面或者在最后一行下面插入是不会跨行的但是可能会跨列。
对于中间的行,主要参照当前行,如果当前行跨行,则新增行也跨行,如果当前行单元格结束跨行,则新增的上方插入行跨行,下方插入行不跨行,如果当前行单元格开始跨行,则新增的上方插入行不跨行,下发插入行跨行。
主要思路就是这样,插入的时候需要得到真实位置的单元格,代码如下:
*/
// 按位置得到单元格(考虑跨列合并情况)
public Tc getTcByPosition(List<Tc> tcList, int position) {
int k = 0;
for (int i = 0, len = tcList.size(); i < len; i++) {
Tc tc = tcList.get(i);
TcPr trPr = tc.getTcPr();
if (trPr != null) {
GridSpan gridSpan = trPr.getGridSpan();
if (gridSpan != null) {
k += gridSpan.getVal().intValue() - 1;
}
}
if (k >= position) {
return tcList.get(i);
}
k++;
}
if (position < tcList.size()) {
return tcList.get(position);
}
return null;
}
示例4: applyGridSpan
import org.docx4j.wml.TcPrInner.GridSpan; //导入依赖的package包/类
private static void applyGridSpan( final Tc cell, final int colSpan, final String rowSpan, int w, boolean mergedVertical ) {
TcPr tcPr = factory.createTcPr();
TblWidth tblWidth = factory.createTblWidth();
tblWidth.setType( "dxa" );
tblWidth.setW( BigInteger.valueOf( w*colSpan ) );
tcPr.setTcW( tblWidth );
if ( colSpan > 1) {
GridSpan gridSpan = factory.createTcPrInnerGridSpan();
gridSpan.setVal(BigInteger.valueOf(colSpan));
tcPr.setGridSpan(gridSpan);
}
if ( mergedVertical ) {
//logger.debug(" this is vertical span");
VMerge gridVSpan = factory.createTcPrInnerVMerge();
if (rowSpan != null)
gridVSpan.setVal(rowSpan);
tcPr.setVMerge(gridVSpan);
}
cell.setTcPr(tcPr);
}