Summary: | Failed to find a matching shared formula record | ||
---|---|---|---|
Product: | POI | Reporter: | David Roe <d.roe> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | zjuwufan |
Priority: | P2 | ||
Version: | 3.8-dev | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | All | ||
Attachments: |
Minimal test case
Move exception from findFormulaGroupForCell to linkSharedFormulaRecord |
Created attachment 28227 [details]
Move exception from findFormulaGroupForCell to linkSharedFormulaRecord
I've had another look at the source code and findFormulaGroupForCell is called from two places: linkSharedFormulaRecord and getRecordForFirstCell. linkSharedFormulaRecord seems to deal only with shared formulas and so I think the exception is correct in that case. However, getRecordForFirstCell deals with tables and arrays and it makes sense there for findFormulaGroupForCell to return null instead of throwing an exception. The code in getRecordForFirstCell even checks for null (which won't be possible with the current exception-throwing code). It seems with the current code, a spreadsheet with a shared formula cannot contain any arrays or tables. I have attached a patch that moves the exception into linkSharedFormulaRecord. I think the TODO comment could also be removed as that file seems to work fine (as mentioned in my earlier comment). |
Created attachment 28209 [details] Minimal test case I'm running into an error "Failed to find a matching shared formula record" when saving a spreadsheet. I've whittled it down to a minimal test case which I've attached. Simply loading and saving this file causes the error. I had to remove some sensitive stuff so there are a few formula errors but the file is still valid. I had a look at the code in org.apache.poi.hssf.record.aggregates.SharedValueManager.findFormulaGroupForCell where the exception is thrown. It mentions 15228.xls which I tried loading and saving and it worked fine.