Search in sources :

Example 1 with StylesCache

use of com.genexus.gxoffice.poi.xssf.StylesCache in project JavaClasses by genexuslabs.

the class ExcelDocument method Open.

public short Open(String fileName) {
    resetError();
    if (fileName.indexOf('.') == -1) {
        fileName += ".xlsx";
    }
    try {
        if (!template.equals("")) {
            GXFile templateFile = new GXFile(template);
            if (templateFile.exists()) {
                workBook = new SXSSFWorkbook(new XSSFWorkbook(templateFile.getStream()));
            } else {
                // Invalid template
                errCod = 4;
                errDescription = "Invalid template.";
                return errCod;
            }
        } else {
            GXFile file = new GXFile("", fileName, Constants.EXTERNAL_UPLOAD_ACL, GxFileInfoSourceType.Unknown);
            if (file.exists()) {
                // System.out.println("Opening..");
                workBook = new SXSSFWorkbook(new XSSFWorkbook(file.getStream()));
            } else {
                // System.out.println("Creating..");
                workBook = new SXSSFWorkbook();
            }
        }
        this.selectFirstSheet();
        xlsFileName = fileName.toString();
        stylesCache = new StylesCache(workBook);
    } catch (Exception e) {
        // error creando xlsx file
        errCod = 10;
        errDescription = "Could not open file.";
        System.err.println("GXOffice Error: " + e.toString());
        return errCod;
    }
    return 0;
}
Also used : StylesCache(com.genexus.gxoffice.poi.xssf.StylesCache) SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) GXFile(com.genexus.util.GXFile)

Aggregations

StylesCache (com.genexus.gxoffice.poi.xssf.StylesCache)1 GXFile (com.genexus.util.GXFile)1 SXSSFWorkbook (org.apache.poi.xssf.streaming.SXSSFWorkbook)1 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)1