Search in sources :

Example 1 with XSSFTestDataSamples.openSampleWorkbook

use of org.apache.poi.xssf.XSSFTestDataSamples.openSampleWorkbook in project poi by apache.

the class TestXSSFSheet method runGetTopRow.

private void runGetTopRow(String file, boolean isXSSF, int... topRows) throws IOException {
    final Workbook wb = (isXSSF) ? XSSFTestDataSamples.openSampleWorkbook(file) : HSSFTestDataSamples.openSampleWorkbook(file);
    for (int si = 0; si < wb.getNumberOfSheets(); si++) {
        Sheet sh = wb.getSheetAt(si);
        assertNotNull(sh.getSheetName());
        assertEquals("Did not match for sheet " + si, topRows[si], sh.getTopRow());
    }
    // for XSSF also test with SXSSF
    if (isXSSF) {
        Workbook swb = new SXSSFWorkbook((XSSFWorkbook) wb);
        for (int si = 0; si < swb.getNumberOfSheets(); si++) {
            Sheet sh = swb.getSheetAt(si);
            assertNotNull(sh.getSheetName());
            assertEquals("Did not match for sheet " + si, topRows[si], sh.getTopRow());
        }
        swb.close();
    }
    wb.close();
}
Also used : SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) BaseTestXSheet(org.apache.poi.ss.usermodel.BaseTestXSheet) Sheet(org.apache.poi.ss.usermodel.Sheet) XSSFTestDataSamples.openSampleWorkbook(org.apache.poi.xssf.XSSFTestDataSamples.openSampleWorkbook) SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook)

Example 2 with XSSFTestDataSamples.openSampleWorkbook

use of org.apache.poi.xssf.XSSFTestDataSamples.openSampleWorkbook in project poi by apache.

the class TestXSSFSheet method testInsertCommentsToClonedSheet.

/**
     * See bug #52425
     */
@Test
public void testInsertCommentsToClonedSheet() {
    Workbook wb = XSSFTestDataSamples.openSampleWorkbook("52425.xlsx");
    CreationHelper helper = wb.getCreationHelper();
    Sheet sheet2 = wb.createSheet("Sheet 2");
    Sheet sheet3 = wb.cloneSheet(0);
    wb.setSheetName(2, "Sheet 3");
    // Adding Comment to new created Sheet 2
    addComments(helper, sheet2);
    // Adding Comment to cloned Sheet 3
    addComments(helper, sheet3);
}
Also used : CreationHelper(org.apache.poi.ss.usermodel.CreationHelper) BaseTestXSheet(org.apache.poi.ss.usermodel.BaseTestXSheet) Sheet(org.apache.poi.ss.usermodel.Sheet) XSSFTestDataSamples.openSampleWorkbook(org.apache.poi.xssf.XSSFTestDataSamples.openSampleWorkbook) SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) Test(org.junit.Test)

Example 3 with XSSFTestDataSamples.openSampleWorkbook

use of org.apache.poi.xssf.XSSFTestDataSamples.openSampleWorkbook in project poi by apache.

the class TestXSSFSheet method runGetLeftCol.

private void runGetLeftCol(String file, boolean isXSSF, int... topRows) throws IOException {
    final Workbook wb = (isXSSF) ? XSSFTestDataSamples.openSampleWorkbook(file) : HSSFTestDataSamples.openSampleWorkbook(file);
    for (int si = 0; si < wb.getNumberOfSheets(); si++) {
        Sheet sh = wb.getSheetAt(si);
        assertNotNull(sh.getSheetName());
        assertEquals("Did not match for sheet " + si, topRows[si], sh.getLeftCol());
    }
    // for XSSF also test with SXSSF
    if (isXSSF) {
        Workbook swb = new SXSSFWorkbook((XSSFWorkbook) wb);
        for (int si = 0; si < swb.getNumberOfSheets(); si++) {
            Sheet sh = swb.getSheetAt(si);
            assertNotNull(sh.getSheetName());
            assertEquals("Did not match for sheet " + si, topRows[si], sh.getLeftCol());
        }
        swb.close();
    }
    wb.close();
}
Also used : SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) BaseTestXSheet(org.apache.poi.ss.usermodel.BaseTestXSheet) Sheet(org.apache.poi.ss.usermodel.Sheet) XSSFTestDataSamples.openSampleWorkbook(org.apache.poi.xssf.XSSFTestDataSamples.openSampleWorkbook) SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook)

Aggregations

BaseTestXSheet (org.apache.poi.ss.usermodel.BaseTestXSheet)3 Sheet (org.apache.poi.ss.usermodel.Sheet)3 Workbook (org.apache.poi.ss.usermodel.Workbook)3 XSSFTestDataSamples.openSampleWorkbook (org.apache.poi.xssf.XSSFTestDataSamples.openSampleWorkbook)3 SXSSFWorkbook (org.apache.poi.xssf.streaming.SXSSFWorkbook)3 CreationHelper (org.apache.poi.ss.usermodel.CreationHelper)1 Test (org.junit.Test)1