Ahmad Nadeem
Ahmad Nadeem

Reputation: 2144

File size issue. while poi read write

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 same file (same data ) is written in one go.

Upvotes: 2

Views: 1847

Answers (2)

Randomness
Randomness

Reputation: 620

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...

Upvotes: 4

JasonV.com
JasonV.com

Reputation: 247

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.

Upvotes: 3

Related Questions