use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth in project poi by apache.
the class XWPFTable method getCellMarginRight.
public int getCellMarginRight() {
int margin = 0;
CTTblPr tblPr = getTrPr();
CTTblCellMar tcm = tblPr.getTblCellMar();
if (tcm != null) {
CTTblWidth tw = tcm.getRight();
if (tw != null) {
margin = tw.getW().intValue();
}
}
return margin;
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth in project poi by apache.
the class XWPFTable method getCellMarginLeft.
public int getCellMarginLeft() {
int margin = 0;
CTTblPr tblPr = getTrPr();
CTTblCellMar tcm = tblPr.getTblCellMar();
if (tcm != null) {
CTTblWidth tw = tcm.getLeft();
if (tw != null) {
margin = tw.getW().intValue();
}
}
return margin;
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth in project poi by apache.
the class XWPFTable method getCellMarginBottom.
public int getCellMarginBottom() {
int margin = 0;
CTTblPr tblPr = getTrPr();
CTTblCellMar tcm = tblPr.getTblCellMar();
if (tcm != null) {
CTTblWidth tw = tcm.getBottom();
if (tw != null) {
margin = tw.getW().intValue();
}
}
return margin;
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth in project Gargoyle by callakrsos.
the class MSWord method addToTable.
/**
* 테이블을 추가한다.
*
* List의 로우는 각 행을 의미. TreeSet은 테이블 컬럼Index 데이터를 의미.
*
* @param list
*/
public XWPFTable addToTable(List<List<String>> list, ITableCustomProperty property) /*
* ,
* ThFunction
* <
* ,
* U
* ,
* V
* ,
* R
* >
*/
{
if (list == null || list.isEmpty()) {
return null;
}
// -- OR --
// open an existing empty document with styles already defined
// XWPFDocument doc = new XWPFDocument(new
// FileInputStream("base_document.docx"));
int rowSize = list.size();
int colSize = list.get(0).size();
XWPFTable table = doc.createTable(rowSize, colSize);
// Set the table style. If the style is not defined, the table style
// will become "Normal".
{
CTTblPr tblPr = table.getCTTbl().getTblPr();
CTString styleStr = tblPr.addNewTblStyle();
styleStr.setVal("StyledTable");
}
/* Table Width조절을 위한 작업 */
{
CTTbl ctTbl = table.getCTTbl();
CTTblPr tblPr = ctTbl.getTblPr();
CTTblWidth tblW = tblPr.getTblW();
// 화면에 WIDTH를 딱 맞춤.
tblW.setW(BigInteger.valueOf(5000));
tblW.setType(STTblWidth.PCT);
}
// Get a list of the rows in the table
// List<XWPFTableRow> rows = table.getRows();
int rowCt = 0;
int colCt = 0;
for (List<String> set : list) {
XWPFTableRow row = table.getRow(rowCt);
CTTrPr trPr = row.getCtRow().addNewTrPr();
// set row height; units = twentieth of a point, 360 = 0.25"
CTHeight ht = trPr.addNewTrHeight();
ht.setVal(BigInteger.valueOf(/* 360 */
240));
// get the cells in this row
List<XWPFTableCell> cells = row.getTableCells();
Iterator<String> it = set.iterator();
while (it.hasNext()) {
if (cells.size() == colCt) {
row.createCell();
}
// get a table cell properties element (tcPr)
XWPFTableCell cell = cells.get(colCt);
CTTcPr tcpr = cell.getCTTc().addNewTcPr();
// set vertical alignment to "center"
CTVerticalJc va = tcpr.addNewVAlign();
va.setVal(STVerticalJc.CENTER);
// create cell color element
CTShd ctshd = tcpr.addNewShd();
ctshd.setColor("auto");
ctshd.setVal(STShd.CLEAR);
if (rowCt == 0) {
// header row
ctshd.setFill("FFFE99");
} else if (rowCt % 2 == 0) {
// even row
// FFFFFF : 흰색
ctshd.setFill("D3DFEE");
} else {
// odd row
ctshd.setFill("EDF2F8");
}
// get 1st paragraph in cell's paragraph list
XWPFParagraph para = cell.getParagraphs().get(0);
// create a run to contain the content
// 2015.3.17 fix
// XWPFRun rh = para.createRun();
KrXWPFRun rh = new KrXWPFRun(para.createRun());
rh.setFontFamily(fontName);
// style cell as desired
if (colCt == colSize - 1) {
// last column is 10pt Courier
rh.setFontSize(DEFAULT_FONT_SIZE);
}
String content = it.next();
if (rowCt == 0) {
// header row
rh.setText(content);
rh.setFontSize(H5);
rh.setBold(true);
para.setAlignment(ParagraphAlignment.CENTER);
} else if (rowCt % 2 == 0) {
// even row
addTableText(rh, content);
rh.setSubscript(VerticalAlign.BASELINE);
para.setAlignment(ParagraphAlignment.LEFT);
} else {
addTableText(rh, content);
// odd row
rh.setSubscript(VerticalAlign.BASELINE);
para.setAlignment(ParagraphAlignment.LEFT);
}
colCt++;
}
// for cell
colCt = 0;
rowCt++;
}
if (property != null) {
property.doCustom(table);
}
return table;
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth in project poi by apache.
the class XWPFTable method setWidth.
/**
* @param width
*/
public void setWidth(int width) {
CTTblPr tblPr = getTrPr();
CTTblWidth tblWidth = tblPr.isSetTblW() ? tblPr.getTblW() : tblPr.addNewTblW();
tblWidth.setW(new BigInteger("" + width));
}
Aggregations