Search in sources :

Example 1 with ColumnHelper

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>();
}
Also used : ColumnHelper(org.apache.poi.xssf.usermodel.helpers.ColumnHelper)

Example 2 with ColumnHelper

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();
}
Also used : ColumnHelper(org.apache.poi.xssf.usermodel.helpers.ColumnHelper) XmlException(org.apache.xmlbeans.XmlException) POIXMLDocumentPart(org.apache.poi.POIXMLDocumentPart) POIXMLException(org.apache.poi.POIXMLException) CommentsTable(org.apache.poi.xssf.model.CommentsTable)

Example 3 with ColumnHelper

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();
}
Also used : ColumnHelper(org.apache.poi.xssf.usermodel.helpers.ColumnHelper) CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol) SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) Test(org.junit.Test)

Aggregations

ColumnHelper (org.apache.poi.xssf.usermodel.helpers.ColumnHelper)3 POIXMLDocumentPart (org.apache.poi.POIXMLDocumentPart)1 POIXMLException (org.apache.poi.POIXMLException)1 CommentsTable (org.apache.poi.xssf.model.CommentsTable)1 SXSSFWorkbook (org.apache.poi.xssf.streaming.SXSSFWorkbook)1 XmlException (org.apache.xmlbeans.XmlException)1 Test (org.junit.Test)1 CTCol (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol)1