How to check if date uses 1904 windowing with Apache POI XSSF eventmodel -


i writing program imports xlsx files apache poi eventmodel (sax/xssf). done, can't correct dates.

i parsing cell date value

<c r="d1" s="1">     <v>41319.558333333334</v> </c> 

i using org.apache.poi.ss.usermodel.dateutil class date:

dateutil.getjavacalendar(doble date, bool use1904windowing); 

what should pass use1904windowing correct dates? temporarily use false, gives me correct dates test workbook, know should read value somewhere.

there record datewindow1904record in binary xls format, read using hssf. counterpart in xssf? or should use false?

edit: @rgettman answer pointed me solution, it's not complete. in event model not have xssfworkbook object , can't getctworkbook() of it.

instead can create ctworkbook directly form inputstream:

opcpackage pkg = opcpackage.open(filename); xssfreader r = new xssfreader( pkg ); inputstream workbookxml = r.getworkbookdata(); ctworkbook ctworkbook = ctworkbook.factory.parse(workbookxml); boolean isdate1904 = ctworkbook.getworkbookpr().getdate1904(); 

code described in edit section compiles, return null ctworkbookpr in poi 3.9 code below parses workbook prefix:

opcpackage pkg = opcpackage.open(filename); xssfreader r = new xssfreader( pkg ); inputstream workbookxml = r.getworkbookdata(); workbookdocument doc = workbookdocument.factory.parse(workbookxml); ctworkbook wb = doc.getworkbook(); ctworkbookpr prefix = wb.getworkbookpr(); boolean isdate1904 = prefix.getdate1904(); pkg.close(); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -