/** * Get the total number of columns in this table. * * @return the column count * @since 4.0.0 */ public int getColumnCount() { CTTableColumns tableColumns = ctTable.getTableColumns(); if(tableColumns == null) { return 0; } // Casting to int should be safe here - tables larger than the // sheet (which holds the actual data of the table) can't exists. return (int) tableColumns.getCount(); }
/** * Changes the name of the Table * @param newStyleName The name of the style. * @since 3.17 beta 1 */ public void setStyleName(String newStyleName) { if (newStyleName == null) { if (ctTable.isSetTableStyleInfo()) { ctTable.getTableStyleInfo().unsetName(); } styleName = null; return; } if (! ctTable.isSetTableStyleInfo()) { ctTable.addNewTableStyleInfo(); } ctTable.getTableStyleInfo().setName(newStyleName); styleName = newStyleName; }
/** * @return the name of the Table, if set */ public String getName() { if (name == null) { setName(ctTable.getName()); } return name; }
/** * @return the table style name, if set * @since 3.17 beta 1 */ public String getStyleName() { if (styleName == null && ctTable.isSetTableStyleInfo()) { setStyleName(ctTable.getTableStyleInfo().getName()); } return styleName; }
CTTableStyleInfo style = cttable.addNewTableStyleInfo(); style.setName("TableStyleLight1"); style.setShowColumnStripes(false); cttable.setRef(reference.formatAsString()); cttable.setId(tableId); cttable.setName(name); cttable.setDisplayName(name); CTAutoFilter autoFilter = cttable.addNewAutoFilter(); autoFilter.setRef(reference.formatAsString()); CTTableColumns columns = cttable.addNewTableColumns();
ctTable.setRef(ref); if (ctTable.isSetAutoFilter()) { String filterRef; int totalsRowCount = getTotalsRowCount(); ctTable.getAutoFilter().setRef(filterRef);
CTTableColumns columns = ctTable.getTableColumns(); if (columns == null) { columns = ctTable.addNewTableColumns(); if (ctTable.getRef() != null) {
ctTable.setRef("A1:H" + (sheet.getLastRowNum() + 1)); // adjust reference as needed ctTable.unsetSortState(); // if you had sorted the data in Excel before reading the file, CTTableColumns ctColumns = ctTable.getTableColumns(); // setting new table columns will
public void processTable(XLXContext context, String tableStartRef) { int col = table.getEndCellReference().getCol(); long currentRow = context.getCurrentRow() - 1; int totalsRowCount = (int) table.getCTTable().getTotalsRowCount(); CTAutoFilter filter = table.getCTTable().getAutoFilter(); if(filter != null){ String autoFilterRef = new CellReference((int) (currentRow - totalsRowCount),col).formatAsString(); table.getCTTable().getAutoFilter().setRef(tableStartRef + ":" + autoFilterRef); } String tableEndRef = new CellReference((int)currentRow,col).formatAsString(); table.getCTTable().setRef(tableStartRef + ":" + tableEndRef); context.processTable(table); }
CTTable cttable = table.getCTTable(); table.setDisplayName("table"); cttable.setRef("A1:C4"); cttable.setId(1); CTTableColumns columns = cttable.addNewTableColumns(); columns.setCount(3);
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); }
table.getCTTable().addNewTableStyleInfo(); table.getCTTable().getTableStyleInfo().setName("TableStyleMedium2");
public void parse(Table table) { final String tableName = table.getCTTable().getName(); int end = table.getEndCellReference().getRow(); TableNode tableNode = sheetParser.createTableNode(sheet,top,table); top.getChildren().add(tableNode); int headerRowCount = (int) table.getCTTable().getHeaderRowCount(); if(headerRowCount > 0){ Node header = parseHeader(tableNode); tableNode.addHeader(header); } ForEachNode forEach = new ForEachNode(sheet); tableNode.addLoop(forEach); forEach.setRows(new TableExpression(tableName)); XSSFRow template = sheet.getRow(row.getRowNum() + headerRowCount); Node templateNode = sheetParser.createRowNode(sheet, template ); for( int i = 0; i < template.getLastCellNum(); i++){ buildTableCell(table,templateNode, template.getCell(i, Row.CREATE_NULL_AS_BLANK)); } forEach.getChildren().add(templateNode ); addTotals(tableNode,templateNode); sheetParser.setCurrentRow(end + 1); }
private CTConnection buildConnection(XLXContext context) { CTConnection connection = connections.addNewConnection(); connection.setId(connections.getConnectionArray().length); connection.setName(ctTable.getName()); connection.setType(4); connection.setRefreshedVersion((short) 0); connection.setBackground(true); CTWebPr webPtr = connection.addNewWebPr(); webPtr.setXml(true); webPtr.setSourceData(true); webPtr.setHtmlFormat(STHtmlFmt.ALL); webPtr.setHtmlTables(true); webPtr.setUrl(context.getReportContext().getMetadata().getId()); ctTable.setTableType(STTableType.Enum.forString("xml")); ctTable.setConnectionId(connection.getId()); return connection; }
/** * Changes the display name of the Table * @param name to use */ public void setDisplayName(String name) { ctTable.setDisplayName(name); }
/** * @return the display name of the Table, if set */ public String getDisplayName() { return ctTable.getDisplayName(); }
CTTableStyleInfo table_style = cttable.addNewTableStyleInfo(); table_style.setName("TableStyleMedium9"); cttable.setRef(my_data_range.formatAsString()); cttable.setDisplayName("MYTABLE"); /* this is the display name of the table */ cttable.setName("Test"); /* This maps to "displayName" attribute in <table>, OOXML */ cttable.setId(1L); //id attribute against table as long value CTTableColumns columns = cttable.addNewTableColumns();
ctTable.setRef(ref); if (ctTable.isSetAutoFilter()) { ctTable.getAutoFilter().setRef(ref);