Search in sources :

Example 6 with CTWorksheet

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

the class TestXSSFPrintSetup method testSetGetDraft.

public void testSetGetDraft() {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    CTPageSetup pSetup = worksheet.addNewPageSetup();
    pSetup.setDraft(false);
    XSSFPrintSetup printSetup = new XSSFPrintSetup(worksheet);
    assertEquals(false, printSetup.getDraft());
    printSetup.setDraft(true);
    assertEquals(true, pSetup.getDraft());
}
Also used : CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTPageSetup(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetup)

Example 7 with CTWorksheet

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

the class TestXSSFPrintSetup method testSetGetNoColor.

public void testSetGetNoColor() {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    CTPageSetup pSetup = worksheet.addNewPageSetup();
    pSetup.setBlackAndWhite(false);
    XSSFPrintSetup printSetup = new XSSFPrintSetup(worksheet);
    assertEquals(false, printSetup.getNoColor());
    printSetup.setNoColor(true);
    assertEquals(true, pSetup.getBlackAndWhite());
}
Also used : CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTPageSetup(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetup)

Example 8 with CTWorksheet

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

the class TestXSSFPrintSetup method testSetGetHVResolution.

public void testSetGetHVResolution() {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    CTPageSetup pSetup = worksheet.addNewPageSetup();
    pSetup.setHorizontalDpi(120);
    pSetup.setVerticalDpi(100);
    XSSFPrintSetup printSetup = new XSSFPrintSetup(worksheet);
    assertEquals(120, printSetup.getHResolution());
    assertEquals(100, printSetup.getVResolution());
    printSetup.setHResolution((short) 150);
    printSetup.setVResolution((short) 130);
    assertEquals(150, pSetup.getHorizontalDpi());
    assertEquals(130, pSetup.getVerticalDpi());
}
Also used : CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTPageSetup(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetup)

Example 9 with CTWorksheet

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

the class TestXSSFPrintSetup method testSetGetFitWidthHeight.

public void testSetGetFitWidthHeight() {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    CTPageSetup pSetup = worksheet.addNewPageSetup();
    pSetup.setFitToWidth(50);
    pSetup.setFitToHeight(99);
    XSSFPrintSetup printSetup = new XSSFPrintSetup(worksheet);
    assertEquals(50, printSetup.getFitWidth());
    assertEquals(99, printSetup.getFitHeight());
    printSetup.setFitWidth((short) 66);
    printSetup.setFitHeight((short) 80);
    assertEquals(66, pSetup.getFitToWidth());
    assertEquals(80, pSetup.getFitToHeight());
}
Also used : CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTPageSetup(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetup)

Example 10 with CTWorksheet

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

the class TestColumnHelper method testGetSetColDefaultStyle.

@Test
public void testGetSetColDefaultStyle() throws IOException {
    XSSFWorkbook workbook = new XSSFWorkbook();
    XSSFSheet sheet = workbook.createSheet();
    CTWorksheet ctWorksheet = sheet.getCTWorksheet();
    ColumnHelper columnHelper = sheet.getColumnHelper();
    // POI column 3, OOXML column 4
    CTCol col = columnHelper.getOrCreateColumn1Based(4, false);
    assertNotNull(col);
    assertNotNull(columnHelper.getColumn(3, false));
    columnHelper.setColDefaultStyle(3, 2);
    assertEquals(2, columnHelper.getColDefaultStyle(3));
    assertEquals(-1, columnHelper.getColDefaultStyle(4));
    StylesTable stylesTable = workbook.getStylesSource();
    CTXf cellXf = CTXf.Factory.newInstance();
    cellXf.setFontId(0);
    cellXf.setFillId(0);
    cellXf.setBorderId(0);
    cellXf.setNumFmtId(0);
    cellXf.setXfId(0);
    stylesTable.putCellXf(cellXf);
    CTCol col_2 = ctWorksheet.getColsArray(0).addNewCol();
    col_2.setMin(10);
    col_2.setMax(12);
    col_2.setStyle(1);
    assertEquals(1, columnHelper.getColDefaultStyle(11));
    XSSFCellStyle cellStyle = new XSSFCellStyle(0, 0, stylesTable, null);
    columnHelper.setColDefaultStyle(11, cellStyle);
    assertEquals(0, col_2.getStyle());
    assertEquals(1, columnHelper.getColDefaultStyle(10));
    workbook.close();
}
Also used : CTXf(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) XSSFCellStyle(org.apache.poi.xssf.usermodel.XSSFCellStyle) CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTCol(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol) StylesTable(org.apache.poi.xssf.model.StylesTable) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) 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