Search in sources :

Example 26 with CTWorksheet

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet in project poi by apache.

the class TestXSSFPrintSetup method testSetGetScale.

public void testSetGetScale() {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    CTPageSetup pSetup = worksheet.addNewPageSetup();
    pSetup.setScale(9);
    XSSFPrintSetup printSetup = new XSSFPrintSetup(worksheet);
    assertEquals(9, printSetup.getScale());
    printSetup.setScale((short) 100);
    assertEquals(100, pSetup.getScale());
}
Also used : CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTPageSetup(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetup)

Example 27 with CTWorksheet

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet in project poi by apache.

the class TestXSSFBugs method bug49325.

/**
     * ensure that CTPhoneticPr is loaded by the ooxml test suite so that it is included in poi-ooxml-schemas
     */
@Test
public void bug49325() throws IOException {
    XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49325.xlsx");
    CTWorksheet sh = wb.getSheetAt(0).getCTWorksheet();
    assertNotNull(sh.getPhoneticPr());
    wb.close();
}
Also used : CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) Test(org.junit.Test)

Example 28 with CTWorksheet

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet in project poi by apache.

the class SXSSFSheet method setWorksheetOutlineLevelRow.

private void setWorksheetOutlineLevelRow() {
    CTWorksheet ct = _sh.getCTWorksheet();
    CTSheetFormatPr pr = ct.isSetSheetFormatPr() ? ct.getSheetFormatPr() : ct.addNewSheetFormatPr();
    if (outlineLevelRow > 0) {
        pr.setOutlineLevelRow((short) outlineLevelRow);
    }
}
Also used : CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTSheetFormatPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetFormatPr)

Example 29 with CTWorksheet

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet in project poi by apache.

the class TestColumnHelper method createHiddenAndBestFitColsWithHelper.

/**
     * Creates and adds a hidden column and then a best fit column with the given min/max pairs.
     * Suitable for testing handling of overlap. 
     */
private static CTCols createHiddenAndBestFitColsWithHelper(int hiddenMin, int hiddenMax, int bestFitMin, int bestFitMax) {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    ColumnHelper helper = new ColumnHelper(worksheet);
    CTCols cols = worksheet.getColsArray(0);
    CTCol hidden = createCol(hiddenMin, hiddenMax);
    hidden.setHidden(true);
    helper.addCleanColIntoCols(cols, hidden);
    CTCol bestFit = createCol(bestFitMin, bestFitMax);
    bestFit.setBestFit(true);
    helper.addCleanColIntoCols(cols, bestFit);
    return cols;
}
Also used : CTCols(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols) CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol)

Example 30 with CTWorksheet

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet in project poi by apache.

the class TestColumnHelper method testGetColumn.

@Test
public void testGetColumn() {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    CTCols cols1 = worksheet.addNewCols();
    CTCol col1 = cols1.addNewCol();
    col1.setMin(1);
    col1.setMax(1);
    col1.setWidth(88);
    col1.setHidden(true);
    CTCol col2 = cols1.addNewCol();
    col2.setMin(2);
    col2.setMax(3);
    CTCols cols2 = worksheet.addNewCols();
    CTCol col4 = cols2.addNewCol();
    col4.setMin(3);
    col4.setMax(6);
    // Remember - POI column 0 == OOXML column 1
    ColumnHelper helper = new ColumnHelper(worksheet);
    assertNotNull(helper.getColumn(0, false));
    assertNotNull(helper.getColumn(1, false));
    assertEquals(88.0, helper.getColumn(0, false).getWidth(), 0.0);
    assertEquals(0.0, helper.getColumn(1, false).getWidth(), 0.0);
    assertTrue(helper.getColumn(0, false).getHidden());
    assertFalse(helper.getColumn(1, false).getHidden());
    assertNull(helper.getColumn(99, false));
    assertNotNull(helper.getColumn(5, false));
}
Also used : CTCols(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols) CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol) Test(org.junit.Test)

Aggregations

CTWorksheet (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet)32 CTPageSetup (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetup)13 Test (org.junit.Test)11 CTCol (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol)7 SXSSFWorkbook (org.apache.poi.xssf.streaming.SXSSFWorkbook)6 CTCols (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols)6 POIXMLException (org.apache.poi.POIXMLException)2 InvalidFormatException (org.apache.poi.openxml4j.exceptions.InvalidFormatException)2 PackageRelationship (org.apache.poi.openxml4j.opc.PackageRelationship)2 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)2 StylesTable (org.apache.poi.xssf.model.StylesTable)2 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)2 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)2 CTXf (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 QName (javax.xml.namespace.QName)1