use of org.apache.poi.xssf.usermodel.helpers.ColumnHelper in project poi by apache.
the class XSSFSheet method onDocumentCreate.
/**
* Initialize worksheet data when creating a new sheet.
*/
@Override
protected void onDocumentCreate() {
worksheet = newSheet();
initRows(worksheet);
columnHelper = new ColumnHelper(worksheet);
hyperlinks = new ArrayList<XSSFHyperlink>();
}
use of org.apache.poi.xssf.usermodel.helpers.ColumnHelper in project poi by apache.
the class XSSFSheet method read.
protected void read(InputStream is) throws IOException {
try {
worksheet = WorksheetDocument.Factory.parse(is, DEFAULT_XML_OPTIONS).getWorksheet();
} catch (XmlException e) {
throw new POIXMLException(e);
}
initRows(worksheet);
columnHelper = new ColumnHelper(worksheet);
// Look for bits we're interested in
for (RelationPart rp : getRelationParts()) {
POIXMLDocumentPart p = rp.getDocumentPart();
if (p instanceof CommentsTable) {
sheetComments = (CommentsTable) p;
}
if (p instanceof XSSFTable) {
tables.put(rp.getRelationship().getId(), (XSSFTable) p);
}
if (p instanceof XSSFPivotTable) {
getWorkbook().getPivotTables().add((XSSFPivotTable) p);
}
}
// Process external hyperlinks for the sheet, if there are any
initHyperlinks();
}
use of org.apache.poi.xssf.usermodel.helpers.ColumnHelper in project poi by apache.
the class TestXSSFSheet method autoSizeColumn.
@Test
public void autoSizeColumn() throws IOException {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Sheet 1");
sheet.createRow(0).createCell(13).setCellValue("test");
sheet.autoSizeColumn(13);
ColumnHelper columnHelper = sheet.getColumnHelper();
CTCol col = columnHelper.getColumn(13, false);
assertTrue(col.getBestFit());
workbook.close();
}
Aggregations