<changes>
<release version="3.7-beta3" date="2010-??-??">
+ <action dev="poi-developers" type="fix">49907 - fixed inconsistent behaviour between HSSF and XSSF when creating consecutive names</action>
<action dev="poi-developers" type="add">Add getMimeType() method to HWPF Picture, alongside existing file extension</action>
<action dev="poi-developers" type="add">Add code for reading Ole10Native data</action>
<action dev="poi-developers" type="add">Add getMimeType() method to HSSF/XSSF PictureData, alongside existing file extension</action>
{
LinkTable linkTable = getOrCreateLinkTable();
- if(linkTable.nameAlreadyExists(name)) {
- throw new IllegalArgumentException(
- "You are trying to assign a duplicated name record: "
- + name.getNameText());
- }
linkTable.addName(name);
return name;
NameRecord name = new NameRecord(builtInName, sheetNumber);
- while(linkTable.nameAlreadyExists(name)) {
+ if(linkTable.nameAlreadyExists(name)) {
throw new RuntimeException("Builtin (" + builtInName
+ ") already exists for sheet (" + sheetNumber + ")");
}
}
public XSSFName createName() {
- XSSFName name = new XSSFName(CTDefinedName.Factory.newInstance(), this);
+ CTDefinedName ctName = CTDefinedName.Factory.newInstance();
+ ctName.setName("");
+ XSSFName name = new XSSFName(ctName, this);
namedRanges.add(name);
return name;
}
n.setFunction(false);
assertFalse(n.isFunctionName());
}
+
+ public final void testDefferedSetting() {
+ Workbook wb = _testDataProvider.createWorkbook();
+ Name n1 = wb.createName();
+ assertNull(n1.getRefersToFormula());
+ assertEquals("", n1.getNameName());
+
+ Name n2 = wb.createName();
+ assertNull(n2.getRefersToFormula());
+ assertEquals("", n2.getNameName());
+
+ n1.setNameName("sale_1");
+ n1.setRefersToFormula("10");
+
+ n2.setNameName("sale_2");
+ n2.setRefersToFormula("20");
+
+ try {
+ n2.setNameName("sale_1");
+ fail("Expected exception");
+ } catch(Exception e){
+ assertEquals("The workbook already contains this name: sale_1", e.getMessage());
+ }
+
+ }
}