use of org.docx4j.wml.Tc in project docx4j-template by vindell.
the class WordprocessingMLPackageRender method addTableCell.
public void addTableCell(Tr tableRow, String content) {
Tc tableCell = factory.createTc();
tableCell.getContent().add(wmlPackage.getMainDocumentPart().createParagraphOfText(content));
tableRow.getContent().add(tableCell);
}
use of org.docx4j.wml.Tc in project docx4j-template by vindell.
the class WordprocessingMLPackageRender method addStyledTableCell.
/**
* 本方法创建单元格, 添加样式后添加到表格行中
*/
public void addStyledTableCell(Tr tableRow, String content, boolean bold, String fontSize) {
Tc tableCell = factory.createTc();
addStyling(tableCell, content, bold, fontSize);
tableRow.getContent().add(tableCell);
}
use of org.docx4j.wml.Tc in project docx4j-template by vindell.
the class AddingAnInlineImageToTable method addTableCell.
/**
* 用给定的段落作为内容向给定的行中添加一个单元格.
*
* @param tr
* @param paragraph
*/
private static void addTableCell(Tr tr, P paragraph) {
Tc tc1 = factory.createTc();
tc1.getContent().add(paragraph);
tr.getContent().add(tc1);
}
use of org.docx4j.wml.Tc in project docx4j-template by vindell.
the class WmlElementUtils method getTcByPosition.
/*
* http://53873039oycg.iteye.com/blog/2194849
* 实现思路:
主要分在当前行上方插入行和在当前行下方插入行。对首尾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;
}
use of org.docx4j.wml.Tc in project docx4j-template by vindell.
the class DocxElementWmlRender method newCell.
public Tc newCell(Tr tableRow, String content) {
Tc tbCell = factory.createTc();
tbCell.getContent().add(newParagraph(content));
tbCell.getContent().add(tbCell);
return tbCell;
}
Aggregations