/** * Gets a boolean value that indicates whether the date systems used in the workbook starts in 1904. * <p> * The default value is false, meaning that the workbook uses the 1900 date system, * where 1/1/1900 is the first day in the system.. * </p> * @return true if the date systems used in the workbook starts in 1904 */ @Internal public boolean isDate1904(){ CTWorkbookPr workbookPr = workbook.getWorkbookPr(); return workbookPr != null && workbookPr.getDate1904(); }
/** * Create a new CTWorkbook with all values set to default */ private void onWorkbookCreate() { workbook = CTWorkbook.Factory.newInstance(); // don't EVER use the 1904 date system CTWorkbookPr workbookPr = workbook.addNewWorkbookPr(); workbookPr.setDate1904(false); setBookViewsIfMissing(); workbook.addNewSheets(); POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties(); expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR); sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, this.xssfFactory); stylesSource = (StylesTable)createRelationship(XSSFRelation.STYLES, this.xssfFactory); stylesSource.setWorkbook(this); namedRanges = new ArrayList<>(); namedRangesByName = new ArrayListValuedHashMap<>(); sheets = new ArrayList<>(); pivotTables = new ArrayList<>(); }
public XlsxSaxAnalyser(AnalysisContext analysisContext) throws IOException, OpenXML4JException, XmlException { this.analysisContext = analysisContext; analysisContext.setCurrentRowNum(0); this.xssfReader = new XSSFReader(OPCPackage.open(analysisContext.getInputStream())); this.sharedStringsTable = this.xssfReader.getSharedStringsTable(); InputStream workbookXml = xssfReader.getWorkbookData(); WorkbookDocument ctWorkbook = WorkbookDocument.Factory.parse(workbookXml); CTWorkbook wb = ctWorkbook.getWorkbook(); CTWorkbookPr prefix = wb.getWorkbookPr(); if (prefix != null) { this.use1904WindowDate = prefix.getDate1904(); } this.analysisContext.setUse1904WindowDate(use1904WindowDate); XSSFReader.SheetIterator ite; sheetSourceList = new ArrayList<SheetSource>(); ite = (XSSFReader.SheetIterator)xssfReader.getSheetsData(); while (ite.hasNext()) { InputStream inputStream = ite.next(); String sheetName = ite.getSheetName(); SheetSource sheetSource = new SheetSource(sheetName, inputStream); sheetSourceList.add(sheetSource); } }
/** * Create a new CTWorkbook with all values set to default */ private void onWorkbookCreate() { workbook = CTWorkbook.Factory.newInstance(); // don't EVER use the 1904 date system CTWorkbookPr workbookPr = workbook.addNewWorkbookPr(); workbookPr.setDate1904(false); setBookViewsIfMissing(); workbook.addNewSheets(); POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties(); expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR); sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, this.xssfFactory); stylesSource = (StylesTable)createRelationship(XSSFRelation.STYLES, this.xssfFactory); stylesSource.setWorkbook(this); namedRanges = new ArrayList<>(); namedRangesByName = new ArrayListValuedHashMap<>(); sheets = new ArrayList<>(); pivotTables = new ArrayList<>(); }
/** * Gets a boolean value that indicates whether the date systems used in the workbook starts in 1904. * <p> * The default value is false, meaning that the workbook uses the 1900 date system, * where 1/1/1900 is the first day in the system.. * </p> * @return true if the date systems used in the workbook starts in 1904 */ protected boolean isDate1904(){ CTWorkbookPr workbookPr = workbook.getWorkbookPr(); return workbookPr != null && workbookPr.getDate1904(); }
/** * Create a new CTWorkbook with all values set to default */ private void onWorkbookCreate() { workbook = CTWorkbook.Factory.newInstance(); // don't EVER use the 1904 date system CTWorkbookPr workbookPr = workbook.addNewWorkbookPr(); workbookPr.setDate1904(false); CTBookViews bvs = workbook.addNewBookViews(); CTBookView bv = bvs.addNewWorkbookView(); bv.setActiveTab(0); workbook.addNewSheets(); POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties(); expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR); sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, XSSFFactory.getInstance()); stylesSource = (StylesTable)createRelationship(XSSFRelation.STYLES, XSSFFactory.getInstance()); namedRanges = new ArrayList<XSSFName>(); sheets = new ArrayList<XSSFSheet>(); }
/** * Gets a boolean value that indicates whether the date systems used in the workbook starts in 1904. * <p> * The default value is false, meaning that the workbook uses the 1900 date system, * where 1/1/1900 is the first day in the system.. * </p> * @return true if the date systems used in the workbook starts in 1904 */ @Internal public boolean isDate1904(){ CTWorkbookPr workbookPr = workbook.getWorkbookPr(); return workbookPr != null && workbookPr.getDate1904(); }
private Object getV(XLXContext context,Object value) throws IOException { if(value == XLSXErrorValue.INSATNCE){ return "#VALUE!"; } if (value instanceof Money){ return ((Money)value).getValue().doubleValue(); } else if (value instanceof Number){ return value.toString(); }else if (value instanceof Date){ boolean date1904 = workbookPr != null && workbookPr.getDate1904(); return String.valueOf(DateUtil.getExcelDate((Date) value, date1904 )); } else if (value instanceof Link) { return ((Link) value).getLabel(); } if(context.getSst() == null || cell.getCellType() == XSSFCell.CELL_TYPE_FORMULA){ return SST.forXML(value.toString().trim()); }else { return context.getSst().add(value.toString().trim()); } }
this.isDate1904 = wd.getWorkbook().getWorkbookPr().getDate1904();