use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet in project poi by apache.
the class TestXSSFPrintSetup method testSetGetNotes.
public void testSetGetNotes() {
CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
CTPageSetup pSetup = worksheet.addNewPageSetup();
pSetup.setCellComments(STCellComments.NONE);
XSSFPrintSetup printSetup = new XSSFPrintSetup(worksheet);
assertEquals(false, printSetup.getNotes());
printSetup.setNotes(true);
assertEquals(PrintCellComments.AS_DISPLAYED.getValue(), pSetup.getCellComments().intValue());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet in project poi by apache.
the class TestXSSFPrintSetup method testSetGetLeftToRight.
public void testSetGetLeftToRight() {
CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
CTPageSetup pSetup = worksheet.addNewPageSetup();
pSetup.setPageOrder(STPageOrder.DOWN_THEN_OVER);
XSSFPrintSetup printSetup = new XSSFPrintSetup(worksheet);
assertEquals(false, printSetup.getLeftToRight());
printSetup.setLeftToRight(true);
assertEquals(PageOrder.OVER_THEN_DOWN.getValue(), pSetup.getPageOrder().intValue());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet in project poi by apache.
the class TestXSSFSheet method removeMergedRegion_lowlevel.
@Test
public void removeMergedRegion_lowlevel() throws IOException {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet();
CTWorksheet ctWorksheet = sheet.getCTWorksheet();
CellRangeAddress region_1 = CellRangeAddress.valueOf("A1:B2");
CellRangeAddress region_2 = CellRangeAddress.valueOf("C3:D4");
CellRangeAddress region_3 = CellRangeAddress.valueOf("E5:F6");
CellRangeAddress region_4 = CellRangeAddress.valueOf("G7:H8");
sheet.addMergedRegion(region_1);
sheet.addMergedRegion(region_2);
sheet.addMergedRegion(region_3);
assertEquals("C3:D4", ctWorksheet.getMergeCells().getMergeCellArray(1).getRef());
assertEquals(3, sheet.getNumMergedRegions());
sheet.removeMergedRegion(1);
assertEquals("E5:F6", ctWorksheet.getMergeCells().getMergeCellArray(1).getRef());
assertEquals(2, sheet.getNumMergedRegions());
sheet.removeMergedRegion(1);
sheet.removeMergedRegion(0);
assertEquals(0, sheet.getNumMergedRegions());
assertNull(" CTMergeCells should be deleted after removing the last merged " + "region on the sheet.", sheet.getCTWorksheet().getMergeCells());
sheet.addMergedRegion(region_1);
sheet.addMergedRegion(region_2);
sheet.addMergedRegion(region_3);
sheet.addMergedRegion(region_4);
// test invalid indexes OOBE
Set<Integer> rmIdx = new HashSet<Integer>(Arrays.asList(5, 6));
sheet.removeMergedRegions(rmIdx);
rmIdx = new HashSet<Integer>(Arrays.asList(1, 3));
sheet.removeMergedRegions(rmIdx);
assertEquals("A1:B2", ctWorksheet.getMergeCells().getMergeCellArray(0).getRef());
assertEquals("E5:F6", ctWorksheet.getMergeCells().getMergeCellArray(1).getRef());
workbook.close();
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet in project poi by apache.
the class TestXSSFSheet method setDefaultColumnStyle.
@Test
public void setDefaultColumnStyle() throws IOException {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet();
CTWorksheet ctWorksheet = sheet.getCTWorksheet();
StylesTable stylesTable = workbook.getStylesSource();
XSSFFont font = new XSSFFont();
font.setFontName("Cambria");
stylesTable.putFont(font);
CTXf cellStyleXf = CTXf.Factory.newInstance();
cellStyleXf.setFontId(1);
cellStyleXf.setFillId(0);
cellStyleXf.setBorderId(0);
cellStyleXf.setNumFmtId(0);
stylesTable.putCellStyleXf(cellStyleXf);
CTXf cellXf = CTXf.Factory.newInstance();
cellXf.setXfId(1);
stylesTable.putCellXf(cellXf);
XSSFCellStyle cellStyle = new XSSFCellStyle(1, 1, stylesTable, null);
assertEquals(1, cellStyle.getFontIndex());
sheet.setDefaultColumnStyle(3, cellStyle);
assertEquals(1, ctWorksheet.getColsArray(0).getColArray(0).getStyle());
workbook.close();
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet in project poi by apache.
the class TestXSSFSheet method createFreezePane_XSSF.
@Test
public void createFreezePane_XSSF() throws IOException {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet();
CTWorksheet ctWorksheet = sheet.getCTWorksheet();
sheet.createFreezePane(2, 4);
assertEquals(2.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit(), 0.0);
assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
sheet.createFreezePane(3, 6, 10, 10);
assertEquals(3.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit(), 0.0);
// assertEquals(10, sheet.getTopRow());
// assertEquals(10, sheet.getLeftCol());
sheet.createSplitPane(4, 8, 12, 12, 1);
assertEquals(8.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getYSplit(), 0.0);
assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
workbook.close();
}
Aggregations