开发者

File size issue. while poi read write

开发者 https://www.devze.com 2023-02-12 03:18 出处:网络
I am using apache poi api to deal with my spread sheet files. I have observed, if we try to edit an existing .xls file it size is not the same as if that 开发者_如何学JAVAsame file (same data ) is wri

I am using apache poi api to deal with my spread sheet files. I have observed, if we try to edit an existing .xls file it size is not the same as if that 开发者_如何学JAVAsame file (same data ) is written in one go.


It is normal for an Excel spreadsheet to grow after being opened or edited. When a spreadsheet is opened in Microsoft Excel the formulas are automatically calculated, so this increases the size of the file. If a spreadsheet is opened by Apache POI it is up to the developer to call the (FormulaEvaluator) to update all the values. When a spreadsheet is read by Apache POI and the formulas have not been evaluated, formula answers may be invalid.


POI will always write out one record per cell

Excel, however, will sometimes bunch several similar sequential cells up into a single record. For example, if you have 3 cells in a row that are blank but styled, then excel will generate a MulBlankRecord which holds all of them. For several cells in a row with simple numbers in them, excel uses a MulRKRecord

When POI reads in a file, it expands all the Mul* records out. At write time, the individual cell records are written, so the file gets slightly bigger. I think there's an entry in the POI bugzilla for the enhancement to get POI to coalesce cells into Mul records, but no-one seems to have volunteered to work on it yet...

0

精彩评论

暂无评论...
验证码 换一张
取 消