Search in sources :

Example 1 with CTWorksheet

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

the class SXSSFSheet method setTabColor.

/**
     * Set background color of the sheet tab
     *
     * @param colorIndex  the indexed color to set, must be a constant from {@link IndexedColors}
     */
public void setTabColor(int colorIndex) {
    CTWorksheet ct = _sh.getCTWorksheet();
    CTSheetPr pr = ct.getSheetPr();
    if (pr == null)
        pr = ct.addNewSheetPr();
    CTColor color = CTColor.Factory.newInstance();
    color.setIndexed(colorIndex);
    pr.setTabColor(color);
}
Also used : CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTSheetPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetPr) CTColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor)

Example 2 with CTWorksheet

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

the class TestXSSFPrintSetup method testSetGetValidSettings.

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

Example 3 with CTWorksheet

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

the class TestXSSFPrintSetup method testSetGetHeaderFooterMargin.

public void testSetGetHeaderFooterMargin() {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    CTPageMargins pMargins = worksheet.addNewPageMargins();
    pMargins.setHeader(1.5);
    pMargins.setFooter(2);
    XSSFPrintSetup printSetup = new XSSFPrintSetup(worksheet);
    assertEquals(1.5, printSetup.getHeaderMargin(), 0.0);
    assertEquals(2.0, printSetup.getFooterMargin(), 0.0);
    printSetup.setHeaderMargin(5);
    printSetup.setFooterMargin(3.5);
    assertEquals(5.0, pMargins.getHeader(), 0.0);
    assertEquals(3.5, pMargins.getFooter(), 0.0);
}
Also used : CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTPageMargins(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageMargins)

Example 4 with CTWorksheet

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

the class TestXSSFPrintSetup method testSetGetUsePage.

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

Example 5 with CTWorksheet

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

the class TestXSSFPrintSetup method testSetGetOrientation.

public void testSetGetOrientation() {
    CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
    CTPageSetup pSetup = worksheet.addNewPageSetup();
    pSetup.setOrientation(STOrientation.PORTRAIT);
    XSSFPrintSetup printSetup = new XSSFPrintSetup(worksheet);
    assertEquals(PrintOrientation.PORTRAIT, printSetup.getOrientation());
    assertEquals(false, printSetup.getLandscape());
    assertEquals(false, printSetup.getNoOrientation());
    printSetup.setOrientation(PrintOrientation.LANDSCAPE);
    assertEquals(pSetup.getOrientation().intValue(), printSetup.getOrientation().getValue());
    assertEquals(true, printSetup.getLandscape());
    assertEquals(false, printSetup.getNoOrientation());
}
Also used : CTWorksheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet) CTPageSetup(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetup)

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