Package org.openxmlformats.schemas.spreadsheetml.x2006.main

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet


        System.err.println(cols1);
    }

    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);

        ColumnHelper helper = new ColumnHelper(worksheet);
View Full Code Here


    }
   
    public void testGetSetColDefaultStyle() {
      XSSFWorkbook workbook = new XSSFWorkbook();
      CTSheet ctSheet = CTSheet.Factory.newInstance();
      CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
      XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, (XSSFWorkbook) workbook);
        ColumnHelper columnHelper = sheet.getColumnHelper();
        CTCol col = columnHelper.getOrCreateColumn(3, false);
        assertNotNull(col);
        assertNotNull(columnHelper.getColumn(3, false));
        columnHelper.setColDefaultStyle(3, 2);
        assertEquals(2, columnHelper.getColDefaultStyle(3));
        assertEquals(-1, columnHelper.getColDefaultStyle(4));
        StylesTable 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);
View Full Code Here

import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;

public class TestColumnHelper extends TestCase {

    public void testCleanColumns() {
        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(13);
        col4.setMax(16384);

        // Test cleaning cols
        assertEquals(2, worksheet.sizeOfColsArray());
        int count = countColumns(worksheet);
        assertEquals(16375, count);
        // Clean columns and test a clean worksheet
        ColumnHelper helper = new ColumnHelper(worksheet);
        assertEquals(1, worksheet.sizeOfColsArray());
        count = countColumns(worksheet);
        assertEquals(16375, count);
        assertEquals((double) 88, helper.getColumn(1, false).getWidth());
        assertTrue(helper.getColumn(1, false).getHidden());
    }
View Full Code Here

    }
   
    public void testGetCellComment() {
        XSSFWorkbook workbook = new XSSFWorkbook();
        CTSheet ctSheet = CTSheet.Factory.newInstance();
        CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
        CTComments ctComments = CTComments.Factory.newInstance();
        CommentsTable sheetComments = new CommentsTable(ctComments);
        XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, workbook, sheetComments);
        assertNotNull(sheet);
       
View Full Code Here

    }
   
    public void testSetCellComment() {
        XSSFWorkbook workbook = new XSSFWorkbook();
        CTSheet ctSheet = CTSheet.Factory.newInstance();
        CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
        XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, workbook);
        Cell cell = sheet.createRow(0).createCell((short)0);
        CTComments ctComments = CTComments.Factory.newInstance();
        CommentsTable comments = new CommentsTable(ctComments);
        XSSFComment comment = comments.addComment();
View Full Code Here

    }
   
    public void testGetActiveCell() {
      Workbook workbook = new XSSFWorkbook();
      CTSheet ctSheet = CTSheet.Factory.newInstance();
      CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
      XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, (XSSFWorkbook) workbook);
      ctWorksheet.addNewSheetViews().addNewSheetView().addNewSelection().setActiveCell("R5");
     
      assertEquals("R5", sheet.getActiveCell());
     
    }
View Full Code Here

    }
   
    public void testCreateFreezePane() {
      Workbook workbook = new XSSFWorkbook();
      CTSheet ctSheet = CTSheet.Factory.newInstance();
      CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
      XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, (XSSFWorkbook) workbook);
      sheet.createFreezePane(2, 4);
      assertEquals((double)2, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit());
      assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
      sheet.createFreezePane(3, 6, 10, 10);
      assertEquals((double)3, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit());
      assertEquals(10, sheet.getTopRow());
      assertEquals(10, sheet.getLeftCol());
      sheet.createSplitPane(4, 8, 12, 12, 1);
      assertEquals((double)8, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getYSplit());
      assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
    }
View Full Code Here

    }
   
    public void testNewMergedRegionAt() {
      Workbook workbook = new XSSFWorkbook();
      CTSheet ctSheet = CTSheet.Factory.newInstance();
      CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
      XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, (XSSFWorkbook) workbook);
      Region region = new Region("B2:D4");
      sheet.addMergedRegion(region);
      assertEquals("B2:D4", sheet.getMergedRegionAt(0).getRegionRef());
    }
View Full Code Here

    }
   
    public void testGetNumMergedRegions() {
      Workbook workbook = new XSSFWorkbook();
      CTSheet ctSheet = CTSheet.Factory.newInstance();
      CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
      XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, (XSSFWorkbook) workbook);
      assertEquals(0, sheet.getNumMergedRegions());
      Region region = new Region("B2:D4");
      sheet.addMergedRegion(region);
      assertEquals(1, sheet.getNumMergedRegions());
View Full Code Here

    }
   
    public void testRemoveMergedRegion() {
      Workbook workbook = new XSSFWorkbook();
      CTSheet ctSheet = CTSheet.Factory.newInstance();
      CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
      XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, (XSSFWorkbook) workbook);
      Region region_1 = new Region("A1:B2");
      Region region_2 = new Region("C3:D4");
      Region region_3 = new Region("E5:F6");
      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());
    }
View Full Code Here

TOP

Related Classes of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.