简体   繁体   中英

documents4j xls xlsx date conversion

When converting from xls to xlsx with documents4j, columns containing a date format of category Custom with a type of dd-mmm-yyyy are being converted to a numeric value - in my case, 24-Nov-1990 in the xls doc becomes 33201 in the xlsx doc. Any ideas on how to correct this? I am using version 1.1.3.

I ran into an issue a bit like this in another app when I read comparable values in with POI. I first had to check if the column was numeric and had a date format and if so then get the date value.

documents4j code:

File target = new File(OUTGOING_FILE_FOLDER + newFileName);
IConverter converter = LocalConverter.builder()
    .baseFolder(new File(BASE_FOLDER))
    .workerPool(20, 25, 2, TimeUnit.SECONDS)
    .processTimeout(5, TimeUnit.SECONDS)
    .build();

Future<Boolean> conversion = converter
    .convert(xlsFile).as(DocumentType.XLS)
    .to(target).as(DocumentType.XLSX)
    .prioritizeWith(1000)
    .schedule();

Thank you, Charles Harvey

The conversion is done by MS Excel in this case. There is nothing that documents4j can do to change the mechanism. If you apply the same conversion in Excel and find out how to adjust the conversion, the same would be applied using documents4j.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM