Package org.apache.poi.xssf.usermodel

Examples of org.apache.poi.xssf.usermodel.XSSFWorkbook


    return createWorkbook(null);
  }
 
  public Workbook createWorkbook(String type){
    if(XLSX.equals(type) || type == null){
      return new XSSFWorkbook();
    }else if(XLS.equals(type)){
      return new HSSFWorkbook();
    }else
      throw new IllegalArgumentException();
  }
View Full Code Here


    assertTrue(second instanceof RenderBox);

    ExcelOutputProcessorMetaData metaData = new ExcelOutputProcessorMetaData(ExcelOutputProcessorMetaData.PAGINATION_FULL);
    metaData.initialize(report.getConfiguration());

    XSSFWorkbook hssfWorkbook = new XSSFWorkbook();
    ExcelColorProducer colorProducer = new StaticExcelColorSupport();
    ExcelFontFactory ff = new ExcelFontFactory(hssfWorkbook, colorProducer);
    CreationHelper ch = hssfWorkbook.getCreationHelper();
    ExcelTextExtractor te = new ExcelTextExtractor(metaData, colorProducer, ch, ff);

    Object compute = te.compute((RenderBox) second);
    assertTrue(compute instanceof RichTextString);
    XSSFRichTextString rt = (XSSFRichTextString) compute;
View Full Code Here

    ExpressionRuntime runtime = new GenericExpressionRuntime(new DefaultTableModel(), 0, new DefaultProcessingContext(report));

    RichTextStyleResolver.resolveStyle(report);

    XSSFWorkbook hssfWorkbook = new XSSFWorkbook();
    ExcelColorProducer colorProducer = new StaticExcelColorSupport();
    ExcelFontFactory ff = new ExcelFontFactory(hssfWorkbook, colorProducer);
    CreationHelper ch = hssfWorkbook.getCreationHelper();
    FastExcelTextExtractor te = new FastExcelTextExtractor(colorProducer, ff, ch);

    Element element = report.getReportHeader().getElement(0);
    Object compute = te.compute(element, runtime);
    assertTrue(compute instanceof RichTextString);
View Full Code Here

        logger.warn("Unable to read predefined xls-data.", e);
      }
    }
    if (isUseXlsxFormat())
    {
      return new XSSFWorkbook();
    }
    else
    {
      return new HSSFWorkbook();
    }
View Full Code Here

    this.dataFormat = workbook.createDataFormat();
    this.hardLimit = hardLimit;

    if (workbook instanceof XSSFWorkbook)
    {
      final XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook;
      final short predefinedStyles = workbook.getNumCellStyles();
      for (short i = 0; i < predefinedStyles; i++)
      {
        final XSSFCellStyle cellStyleAt = xssfWorkbook.getCellStyleAt(i);
        this.styleCache.put(new HSSFCellStyleKey(cellStyleAt), cellStyleAt);
      }
    }
    else
    {
View Full Code Here

    public LinkedHashMap<String,LinkedHashMap> parseFile( InputStream inputFile ) {
        LinkedHashMap<String,LinkedHashMap> fields = null;
       
        try {
           
            XSSFWorkbook workbook = new XSSFWorkbook(inputFile);
            XSSFSheet sheet = workbook.getSheetAt( 0 );
            XSSFRow row = sheet.getRow(0);
           
            Iterator<Cell> cellIt = row.cellIterator();
           
            fields = new LinkedHashMap();
View Full Code Here

    private HashMap<String,Integer> fieldNames = null;

    public void prepareFileRead() throws Exception {
        this.fieldNames = new HashMap<String,Integer>();

        this.readBook = new XSSFWorkbook( new FileInputStream( this.operateFile ) );
        this.readSheet = this.readBook.getSheetAt( 0 );
       
        Iterator<Cell> cellIt = this.readSheet.getRow( 0 ).cellIterator();
        while( cellIt.hasNext() ) {
            Cell currCell = cellIt.next();
View Full Code Here

    _coreProperties = _props.getCoreProperties();
    assertNotNull(_props);
  }

  public void testWorkbookExtendedProperties() {
    XSSFWorkbook workbook = new XSSFWorkbook();
    POIXMLProperties props = workbook.getProperties();
    assertNotNull(props);

    org.apache.poi.POIXMLProperties.ExtendedProperties properties =
        props.getExtendedProperties();

    org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties
        ctProps = properties.getUnderlyingProperties();


    String appVersion = "3.5 beta";
    String application = "POI";

    ctProps.setApplication(application);
    ctProps.setAppVersion(appVersion);

    ctProps = null;
    properties = null;
    props = null;

    XSSFWorkbook newWorkbook =
        XSSFTestDataSamples.writeOutAndReadBack(workbook);

    assertTrue(workbook != newWorkbook);


    POIXMLProperties newProps = newWorkbook.getProperties();
    assertNotNull(newProps);
    org.apache.poi.POIXMLProperties.ExtendedProperties newProperties =
        newProps.getExtendedProperties();

    org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties
View Full Code Here

    /**
     * Test usermodel API for setting custom properties
     */
    public void testCustomProperties() {
        POIXMLDocument wb = new XSSFWorkbook();

        POIXMLProperties.CustomProperties customProps = wb.getProperties().getCustomProperties();
        customProps.addProperty("test-1", "string val");
        customProps.addProperty("test-2", 1974);
        customProps.addProperty("test-3", 36.6);
        //adding a duplicate
        try {
            customProps.addProperty("test-3", 36.6);
            fail("expected exception");
        } catch(IllegalArgumentException e){
            assertEquals("A property with this name already exists in the custom properties", e.getMessage());
        }
        customProps.addProperty("test-4", true);

        wb = XSSFTestDataSamples.writeOutAndReadBack((XSSFWorkbook)wb);
        org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties ctProps =
                wb.getProperties().getCustomProperties().getUnderlyingProperties();
        assertEquals(4, ctProps.sizeOfPropertyArray());
        org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty p;

        p = ctProps.getPropertyArray(0);
        assertEquals("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", p.getFmtid());
View Full Code Here

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class TestWorkbookProtection extends TestCase {

  public void testShouldReadWorkbookProtection() throws Exception {
    XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("workbookProtection_not_protected.xlsx");
    assertFalse(workbook.isStructureLocked());
    assertFalse(workbook.isWindowsLocked());
    assertFalse(workbook.isRevisionLocked());

    workbook = XSSFTestDataSamples.openSampleWorkbook("workbookProtection_workbook_structure_protected.xlsx");
    assertTrue(workbook.isStructureLocked());
    assertFalse(workbook.isWindowsLocked());
    assertFalse(workbook.isRevisionLocked());

    workbook = XSSFTestDataSamples.openSampleWorkbook("workbookProtection_workbook_windows_protected.xlsx");
    assertTrue(workbook.isWindowsLocked());
    assertFalse(workbook.isStructureLocked());
    assertFalse(workbook.isRevisionLocked());

    workbook = XSSFTestDataSamples.openSampleWorkbook("workbookProtection_workbook_revision_protected.xlsx");
    assertTrue(workbook.isRevisionLocked());
    assertFalse(workbook.isWindowsLocked());
    assertFalse(workbook.isStructureLocked());
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.xssf.usermodel.XSSFWorkbook

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.