/** * this method update column header of sheet into table * * @param ctTable * xssf table object * @param title * title of column * @param index * index of column */ private void updateSheetTable(CTTable ctTable, String title, int index) { CTTableColumns tableColumnList = ctTable.getTableColumns(); CTTableColumn column = null; for( int i = 0; tableColumnList.getCount() < index; i++) { column = tableColumnList.addNewTableColumn(); column.setId(i); } column = tableColumnList.getTableColumnArray(index); column.setName(title); }
/** * Get the identifier of this column, which is is unique per table. * * @return the column id * @since 4.0.0 */ public long getId() { return ctTableColumn.getId(); }
/** * Get the name of the column, which is is unique per table. * * @return the column name * @since 4.0.0 */ public String getName() { return ctTableColumn.getName(); }
/** * Get the name of the column, which is is unique per table. * * @return the column name * @since 4.0.0 */ public void setName(String columnName) { ctTableColumn.setName(columnName); }
for(CTTableColumn col : ctTable.getTableColumns().getTableColumnArray()){ CTXmlColumnPr ptr = col.addNewXmlColumnPr(); ptr.setMapId(map.getID()); String elementName = SST.toXMLEment(originalTable.getTableColumns().getTableColumnArray(i++).getName()); col.setUniqueName(col.getName()); ptr.setXpath("/root/row/" + elementName);
/** * Get the XmlColumnPr (XML column properties) if this column has an XML * mapping. * * @return the XmlColumnPr or <code>null</code> if this column has no XML * mapping * @since 4.0.0 */ public XSSFXmlColumnPr getXmlColumnPr() { if (xmlColumnPr == null) { CTXmlColumnPr ctXmlColumnPr = ctTableColumn.getXmlColumnPr(); if (ctXmlColumnPr != null) { xmlColumnPr = new XSSFXmlColumnPr(this, ctXmlColumnPr); } } return xmlColumnPr; }
/** * Set the identifier of this column, which must be unique per table. * * It is up to the caller to enforce the uniqueness of the id. * * @return the column id * @since 4.0.0 */ public void setId(long columnId) { ctTableColumn.setId(columnId); }
void buildTableCell(Table table, Node templateNode, XSSFCell cell) { int start = table.getStartCellReference().getCol(); int end = table.getEndCellReference().getCol(); int cellCol = cell.getColumnIndex(); String axis = findAxisCol(cell); CTTableColumn[] ctCols = table.getCTTable().getTableColumns().getTableColumnArray(); int totalsRowCount = (int) table.getCTTable().getTotalsRowCount(); String cellVal = cell.getStringCellValue().trim(); XLSXExpression expr = new SimpleExpression( cellVal); if(totalsRowCount > 0 && cellCol >= start && cellCol <= end ){ CTTableColumn totalCol = ctCols[cellCol - start]; if(totalCol.isSetTotalsRowFunction()){ expr = new AggregateExpression(expr, Function.valueOf((totalCol.getTotalsRowFunction().toString().toUpperCase()))); } } CellNode cellNode = sheetParser.createCellNode(sheet, cell,cell.getColumnIndex(), expr , templateNode ); cellNode.setAxis(axis); templateNode.getChildren().add(cellNode); }
@Override public void process(XLXContext context) throws Exception { String style = context.getReportContext().getTableStyleName(); if(style != null){ table.getCTTable().getTableStyleInfo().setName(style); } for(CTTableColumn c : table.getCTTable().getTableColumns().getTableColumnArray()){ Object name = CellExpressionParser.parseExpression(c.getName()).evaluate(context); if(name != null){ c.setName(name.toString()); } } if(header != null){ context.setTableStartHeader(); header.process(context); context.endTableHeader(); generateXMLMap(context); } String tableStartRef = startTable(context); long row = context.getCurrentRow(); forEach.process(context); if(row == context.getCurrentRow()){ context.nextRow();//insert empty row } if(totals != null){ totals.process(context); } processTable(context, tableStartRef); }
XSSFCell cell = row.getCell(cellnum); if (cell != null) { col.setName(formatter.formatCellValue(cell));
public List<XSSFXmlColumnPr> getXmlColumnPrs() { if(xmlColumnPr==null){ xmlColumnPr = new Vector<XSSFXmlColumnPr>(); for(CTTableColumn column:ctTable.getTableColumns().getTableColumnList()){ if(column.getXmlColumnPr()!=null){ XSSFXmlColumnPr columnPr = new XSSFXmlColumnPr(this,column,column.getXmlColumnPr()); xmlColumnPr.add(columnPr); } } } return xmlColumnPr; }
/** * Set the identifier of this column, which must be unique per table. * * It is up to the caller to enforce the uniqueness of the id. * * @return the column id * @since 4.0.0 */ public void setId(long columnId) { ctTableColumn.setId(columnId); }
/** * Get the name of the column, which is is unique per table. * * @return the column name * @since 4.0.0 */ public void setName(String columnName) { ctTableColumn.setName(columnName); }
@Deprecated @Removal(version="4.2") public XSSFXmlColumnPr(XSSFTable table, CTTableColumn ctTableColum, CTXmlColumnPr ctXmlColumnPr) { this.table = table; this.tableColumn = table.getColumns().get(table.findColumnIndex(ctTableColum.getName())); this.ctXmlColumnPr = ctXmlColumnPr; }
/** * Get the XmlColumnPr (XML column properties) if this column has an XML * mapping. * * @return the XmlColumnPr or <code>null</code> if this column has no XML * mapping * @since 4.0.0 */ public XSSFXmlColumnPr getXmlColumnPr() { if (xmlColumnPr == null) { CTXmlColumnPr ctXmlColumnPr = ctTableColumn.getXmlColumnPr(); if (ctXmlColumnPr != null) { xmlColumnPr = new XSSFXmlColumnPr(this, ctXmlColumnPr); } } return xmlColumnPr; }
/** * Get the identifier of this column, which is is unique per table. * * @return the column id * @since 4.0.0 */ public long getId() { return ctTableColumn.getId(); }
CTTableColumns ctColumns = ctTable.addNewTableColumns(); CTAutoFilter autofilter = ctTable.addNewAutoFilter(); ctColumns.setCount(table_headers.size()); for(int i = 0; i < table_headers.size(); i++) { CTTableColumn column = ctColumns.addNewTableColumn(); column.setName(table_headers.get(i)); column.setId(i + 1); CTFilterColumn filter = autofilter.addNewFilterColumn(); filter.setColId(i + 1); filter.setShowButton(true); }
/** * Synchronize table headers with cell values in the parent sheet. * Headers <em>must</em> be in sync, otherwise Excel will display a * "Found unreadable content" message on startup. */ @SuppressWarnings("deprecation") public void updateHeaders(){ XSSFSheet sheet = (XSSFSheet)getParent(); CellReference ref = getStartCellReference(); if(ref == null) return; int headerRow = ref.getRow(); int firstHeaderColumn = ref.getCol(); XSSFRow row = sheet.getRow(headerRow); if (row != null && row.getCTRow().validate()) { int cellnum = firstHeaderColumn; for (CTTableColumn col : getCTTable().getTableColumns().getTableColumnArray()) { XSSFCell cell = row.getCell(cellnum); if (cell != null) { col.setName(cell.getStringCellValue()); } cellnum++; } } }