private void AddColumn(CT_Table table, uint index) { var column = new CT_TableColumn(); column.name = "Column" + index; column.id = index + 1; table.tableColumns.tableColumn.Add(column); }
public XSSFXmlColumnPr(XSSFTable table, CT_TableColumn ctTableColum, CT_XmlColumnPr CT_XmlColumnPr) { this.table = table; this.ctTableColumn = ctTableColum; this.ctXmlColumnPr = CT_XmlColumnPr; }
public XSSFXmlColumnPr(XSSFTable table, CT_TableColumn ctTableColum, CT_XmlColumnPr CT_XmlColumnPr) { this.table = table; this.tableColumn = table.GetColumns()[table.FindColumnIndex(ctTableColum.name)]; this.ctXmlColumnPr = CT_XmlColumnPr; }
public XSSFTableColumn CreateColumn(String columnName, int columnIndex) { int columnCount = ColumnCount; if (columnIndex < 0 || columnIndex > columnCount) { throw new ArgumentException("Column index out of bounds"); } // Ensure we have Table Columns CT_TableColumns columns = ctTable.tableColumns; if (columns == null) { columns = ctTable.AddNewTableColumns(); } // check if name is unique and calculate unique column id long nextColumnId = 0; foreach (XSSFTableColumn tableColumn in this.GetColumns()) { if (columnName != null && columnName.Equals(tableColumn.Name, StringComparison.InvariantCultureIgnoreCase)) { throw new ArgumentException("Column '" + columnName + "' already exists. Column names must be unique per table."); } nextColumnId = Math.Max(nextColumnId, tableColumn.Id); } // Bug #62740, the logic was just re-using the existing max ID, not incrementing beyond it. nextColumnId++; // Add the new Column CT_TableColumn column = columns.InsertNewTableColumn(columnIndex); columns.count = columns.count; column.id = (uint)nextColumnId; if (columnName != null) { column.name = columnName; } else { column.name = "Column " + nextColumnId; } /*if (ctTable.@ref != null) * { * // calculate new area * int newColumnCount = columnCount + 1; * CellReference tableStart = StartCellReference; * CellReference tableEnd = EndCellReference; * SpreadsheetVersion version = GetXSSFSheet().GetWorkbook().SpreadsheetVersion; * CellReference newTableEnd = new CellReference(tableEnd.Row, * tableStart.Col + newColumnCount - 1); * AreaReference newTableArea = new AreaReference(tableStart, newTableEnd, version); * * SetCellRef(newTableArea); * }*/ UpdateHeaders(); return(GetColumns()[columnIndex]); }
internal XSSFTableColumn(XSSFTable table, CT_TableColumn ctTableColumn) { this.table = table; this.ctTableColumn = ctTableColumn; }