use of org.docx4j.wml.TcPr in project docx4j-template by vindell.
the class Docx4jStyle_S3 method setCellVMerge.
public void setCellVMerge(Tc tableCell, String mergeVal) {
if (mergeVal != null) {
TcPr tableCellProperties = tableCell.getTcPr();
if (tableCellProperties == null) {
tableCellProperties = new TcPr();
tableCell.setTcPr(tableCellProperties);
}
VMerge merge = new VMerge();
if (!"close".equals(mergeVal)) {
merge.setVal(mergeVal);
}
tableCellProperties.setVMerge(merge);
}
}
use of org.docx4j.wml.TcPr in project docx4j-template by vindell.
the class Docx4jStyle_S3 method setCellWidth.
public void setCellWidth(Tc tableCell, int width) {
if (width > 0) {
TcPr tableCellProperties = tableCell.getTcPr();
if (tableCellProperties == null) {
tableCellProperties = new TcPr();
tableCell.setTcPr(tableCellProperties);
}
TblWidth tableWidth = new TblWidth();
tableWidth.setType("dxa");
tableWidth.setW(BigInteger.valueOf(width));
tableCellProperties.setTcW(tableWidth);
}
}
use of org.docx4j.wml.TcPr in project docx4j-template by vindell.
the class Docx4jStyle_S3 method setCellNoWrap.
public void setCellNoWrap(Tc tableCell) {
TcPr tableCellProperties = tableCell.getTcPr();
if (tableCellProperties == null) {
tableCellProperties = new TcPr();
tableCell.setTcPr(tableCellProperties);
}
BooleanDefaultTrue b = new BooleanDefaultTrue();
b.setVal(true);
tableCellProperties.setNoWrap(b);
}
use of org.docx4j.wml.TcPr in project docx4j-template by vindell.
the class Docx4j_合并单元格_S4_Test method mergeCellsHorizontalByGridSpan.
public void mergeCellsHorizontalByGridSpan(Tbl tbl, int row, int fromCell, int toCell) {
if (row < 0 || fromCell < 0 || toCell < 0) {
return;
}
List<Tr> trList = getTblAllTr(tbl);
if (row > trList.size()) {
return;
}
Tr tr = trList.get(row);
List<Tc> tcList = getTrAllCell(tr);
for (int cellIndex = Math.min(tcList.size() - 1, toCell); cellIndex >= fromCell; cellIndex--) {
Tc tc = tcList.get(cellIndex);
TcPr tcPr = getTcPr(tc);
if (cellIndex == fromCell) {
GridSpan gridSpan = tcPr.getGridSpan();
if (gridSpan == null) {
gridSpan = new GridSpan();
tcPr.setGridSpan(gridSpan);
}
gridSpan.setVal(BigInteger.valueOf(Math.min(tcList.size() - 1, toCell) - fromCell + 1));
} else {
tr.getContent().remove(cellIndex);
}
}
}
use of org.docx4j.wml.TcPr in project docx4j-template by vindell.
the class Docx4j_合并单元格_S4_Test method mergeCellsHorizontal.
/**
* @Description: 跨列合并
*/
public void mergeCellsHorizontal(Tbl tbl, int row, int fromCell, int toCell) {
if (row < 0 || fromCell < 0 || toCell < 0) {
return;
}
List<Tr> trList = getTblAllTr(tbl);
if (row > trList.size()) {
return;
}
Tr tr = trList.get(row);
List<Tc> tcList = getTrAllCell(tr);
for (int cellIndex = fromCell, len = Math.min(tcList.size() - 1, toCell); cellIndex <= len; cellIndex++) {
Tc tc = tcList.get(cellIndex);
TcPr tcPr = getTcPr(tc);
HMerge hMerge = tcPr.getHMerge();
if (hMerge == null) {
hMerge = new HMerge();
tcPr.setHMerge(hMerge);
}
if (cellIndex == fromCell) {
hMerge.setVal("restart");
} else {
hMerge.setVal("continue");
}
}
}
Aggregations