use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn in project poi by apache.
the class XSSFTable method updateHeaders.
/**
* 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.
*
* If calling both {@link #updateReferences()} and
* {@link #updateHeaders()}, {@link #updateReferences()}
* should be called first.
*/
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++;
}
ctColumns = null;
columnMap = null;
xmlColumnPr = null;
commonXPath = null;
}
}
Aggregations