mirror of https://github.com/apache/poi.git
Bugzilla 52527: avoid exception when matching shared formula records in HSSF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1241419 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0c9d5c57e6
commit
8840f717da
|
@ -34,6 +34,7 @@
|
|||
|
||||
<changes>
|
||||
<release version="3.8-beta6" date="2012-??-??">
|
||||
<action dev="poi-developers" type="fix">52527 - avoid exception when matching shared formula records in HSSF</action>
|
||||
<action dev="poi-developers" type="add">52568 - Added methods to set/get an XWPFRun's text color</action>
|
||||
<action dev="poi-developers" type="add">52566 - Added methods to set/get vertical alignment and color in XWPFTableCell</action>
|
||||
<action dev="poi-developers" type="add">52562 - Added methods to get/set a table row's Can't Split and Repeat Header attributes in XWPF</action>
|
||||
|
|
|
@ -158,6 +158,9 @@ public final class SharedValueManager {
|
|||
*/
|
||||
public SharedFormulaRecord linkSharedFormulaRecord(CellReference firstCell, FormulaRecordAggregate agg) {
|
||||
SharedFormulaGroup result = findFormulaGroupForCell(firstCell);
|
||||
if(null == result) {
|
||||
throw new RuntimeException("Failed to find a matching shared formula record");
|
||||
}
|
||||
result.add(agg);
|
||||
return result.getSFR();
|
||||
}
|
||||
|
@ -170,10 +173,6 @@ public final class SharedValueManager {
|
|||
}
|
||||
}
|
||||
SharedFormulaGroup sfg = _groupsCache.get(getKeyForCache(cellRef));
|
||||
if(null == sfg) {
|
||||
// TODO - fix file "15228.xls" so it opens in Excel after rewriting with POI
|
||||
throw new RuntimeException("Failed to find a matching shared formula record");
|
||||
}
|
||||
return sfg;
|
||||
}
|
||||
|
||||
|
|
|
@ -192,4 +192,24 @@ public final class TestSharedValueManager extends TestCase {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void testBug52527() {
|
||||
HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("52527.xls");
|
||||
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
|
||||
|
||||
assertEquals("IF(H3,LINEST(N9:N14,K9:M14,FALSE),LINEST(N8:N14,K8:M14,FALSE))",
|
||||
wb1.getSheetAt(0).getRow(4).getCell(11).getCellFormula());
|
||||
assertEquals("IF(H3,LINEST(N9:N14,K9:M14,FALSE),LINEST(N8:N14,K8:M14,FALSE))",
|
||||
wb2.getSheetAt(0).getRow(4).getCell(11).getCellFormula());
|
||||
|
||||
assertEquals("1/SQRT(J9)",
|
||||
wb1.getSheetAt(0).getRow(8).getCell(10).getCellFormula());
|
||||
assertEquals("1/SQRT(J9)",
|
||||
wb2.getSheetAt(0).getRow(8).getCell(10).getCellFormula());
|
||||
|
||||
assertEquals("1/SQRT(J26)",
|
||||
wb1.getSheetAt(0).getRow(25).getCell(10).getCellFormula());
|
||||
assertEquals("1/SQRT(J26)",
|
||||
wb2.getSheetAt(0).getRow(25).getCell(10).getCellFormula());
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue