Package org.apache.poi.xssf.model

Examples of org.apache.poi.xssf.model.StylesTable


    //get default style
    CellStyle cellStyleAt = workbook.getCellStyleAt(i);
    assertNotNull(cellStyleAt);

    //get custom style
    StylesTable styleSource = workbook.getStylesSource();
    XSSFCellStyle customStyle = new XSSFCellStyle(styleSource);
    XSSFFont font = new XSSFFont();
    font.setFontName("Verdana");
    customStyle.setFont(font);
    int x = styleSource.putStyle(customStyle);
    cellStyleAt = workbook.getCellStyleAt((short)x);
    assertNotNull(cellStyleAt);
  }
View Full Code Here


    assertNotNull(cellStyleAt);
  }

  public void testGetFontAt(){
     XSSFWorkbook workbook = new XSSFWorkbook();
    StylesTable styleSource = workbook.getStylesSource();
    short i = 0;
    //get default font
    Font fontAt = workbook.getFontAt(i);
    assertNotNull(fontAt);

    //get customized font
    XSSFFont customFont = new XSSFFont();
    customFont.setItalic(true);
    int x = styleSource.putFont(customFont);
    fontAt = workbook.getFontAt((short)x);
    assertNotNull(fontAt);
  }
View Full Code Here

  }

  public void testStyles() {
    XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("Formatting.xlsx");

    StylesTable ss = workbook.getStylesSource();
    assertNotNull(ss);
    StylesTable st = ss;

    // Has 8 number formats
    assertEquals(8, st._getNumberFormatSize());
    // Has 2 fonts
    assertEquals(2, st.getFonts().size());
    // Has 2 fills
    assertEquals(2, st.getFills().size());
    // Has 1 border
    assertEquals(1, st.getBorders().size());

    // Add two more styles
    assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
        st.putNumberFormat("testFORMAT"));
    assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
        st.putNumberFormat("testFORMAT"));
    assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 9,
        st.putNumberFormat("testFORMAT2"));
    assertEquals(10, st._getNumberFormatSize());


    // Save, load back in again, and check
    workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);

    ss = workbook.getStylesSource();
    assertNotNull(ss);

    assertEquals(10, st._getNumberFormatSize());
    assertEquals(2, st.getFonts().size());
    assertEquals(2, st.getFills().size());
    assertEquals(1, st.getBorders().size());
  }
View Full Code Here

    */
   public String getText() {
       try {
          ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(container);
          XSSFReader xssfReader = new XSSFReader(container);
          StylesTable styles = xssfReader.getStylesTable();
          XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData();
  
          StringBuffer text = new StringBuffer();
          SheetTextExtractor sheetExtractor = new SheetTextExtractor(text);
         
View Full Code Here

    @Test
    public void setDefaultColumnStyle() {
        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());
View Full Code Here

    /*package*/  CTCfRule getCTCfRule(){
        return _cfRule;
    }

    /*package*/  CTDxf getDxf(boolean create){
        StylesTable styles = _sh.getWorkbook().getStylesSource();
        CTDxf dxf = null;
        if(styles._getDXfsSize() > 0 && _cfRule.isSetDxfId()){
            int dxfId = (int)_cfRule.getDxfId();
            dxf = styles.getDxfAt(dxfId);
        }
        if(create && dxf == null) {
            dxf = CTDxf.Factory.newInstance();
            int dxfId = styles.putDxf(dxf);
            _cfRule.setDxfId(dxfId - 1);
        }
        return dxf;
    }
View Full Code Here

    @Test
    public void setDefaultColumnStyle() {
        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());
View Full Code Here

    //get default style
    CellStyle cellStyleAt = workbook.getCellStyleAt(i);
    assertNotNull(cellStyleAt);

    //get custom style
    StylesTable styleSource = workbook.getStylesSource();
    XSSFCellStyle customStyle = new XSSFCellStyle(styleSource);
    XSSFFont font = new XSSFFont();
    font.setFontName("Verdana");
    customStyle.setFont(font);
    int x = styleSource.putStyle(customStyle);
    cellStyleAt = workbook.getCellStyleAt((short)x);
    assertNotNull(cellStyleAt);
  }
View Full Code Here

    assertNotNull(cellStyleAt);
  }

  public void testGetFontAt(){
     XSSFWorkbook workbook = new XSSFWorkbook();
    StylesTable styleSource = workbook.getStylesSource();
    short i = 0;
    //get default font
    Font fontAt = workbook.getFontAt(i);
    assertNotNull(fontAt);

    //get customized font
    XSSFFont customFont = new XSSFFont();
    customFont.setItalic(true);
    int x = styleSource.putFont(customFont);
    fontAt = workbook.getFontAt((short)x);
    assertNotNull(fontAt);
  }
View Full Code Here

  }

  public void testStyles() {
    XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("Formatting.xlsx");

    StylesTable ss = workbook.getStylesSource();
    assertNotNull(ss);
    StylesTable st = ss;

    // Has 8 number formats
    assertEquals(8, st._getNumberFormatSize());
    // Has 2 fonts
    assertEquals(2, st.getFonts().size());
    // Has 2 fills
    assertEquals(2, st.getFills().size());
    // Has 1 border
    assertEquals(1, st.getBorders().size());

    // Add two more styles
    assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
        st.putNumberFormat("testFORMAT"));
    assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
        st.putNumberFormat("testFORMAT"));
    assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 9,
        st.putNumberFormat("testFORMAT2"));
    assertEquals(10, st._getNumberFormatSize());


    // Save, load back in again, and check
    workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);

    ss = workbook.getStylesSource();
    assertNotNull(ss);

    assertEquals(10, st._getNumberFormatSize());
    assertEquals(2, st.getFonts().size());
    assertEquals(2, st.getFills().size());
    assertEquals(1, st.getBorders().size());
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.xssf.model.StylesTable

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.