renamed Name.setFormula to more descriptive setRefersToFormula, also misc improvements in the site docs

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@719547 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2008-11-21 09:22:07 +00:00
parent e796abd3fa
commit 796a0eea4f
15 changed files with 202 additions and 110 deletions

View File

@ -182,6 +182,7 @@ wb.setSheetName(0, "\u0422\u0435\u0441\u0442\u043E\u0432\u0430\u044F " +
// in case of plain ascii
// wb.setSheetName(0, "HSSF Test");
// create a sheet with 30 rows (0-29)
int rownum;
for (rownum = (short) 0; rownum < 30; rownum++)
{
// create a row

View File

@ -1243,19 +1243,24 @@ Examples:
Name namedCell = wb.createName();
namedCell.setNameName(cname);
String reference = sname+"!A1:A1"; // area reference
namedCell.setReference(reference);
namedCell.setRefersToFormula(reference);
// 2. create named range for a single cell using cellreference
Name namedCell = wb.createName();
namedCell.setNameName(cname);
Name namedCel2 = wb.createName();
namedCel2.setNameName(cname);
String reference = sname+"!A1"; // cell reference
namedCell.setReference(reference);
namedCel2.setRefersToFormula(reference);
// 3. create named range for an area using AreaReference
Name namedCell = wb.createName();
namedCell.setNameName(cname);
Name namedCel3 = wb.createName();
namedCel3.setNameName(cname);
String reference = sname+"!A1:C5"; // area reference
namedCell.setReference(reference);
namedCel3.setRefersToFormula(reference);
// 4. create named formula
Name namedCel4 = wb.createName();
namedCel4.setNameName("my_sum");
namedCel4.setRefersToFormula("SUM(sname+!$I$2:$I$6)");
</source>
<p>
Reading from Named Range / Named Cell
@ -1270,7 +1275,7 @@ Examples:
Name aNamedCell = wb.getNameAt(namedCellIdx);
// retrieve the cell at the named range and test its contents
AreaReference aref = new AreaReference(aNamedCell.getReference());
AreaReference aref = new AreaReference(aNamedCell.getRefersToFormula());
CellReference[] crefs = aref.getAllReferencedCells();
for (int i=0; i&lt;crefs.length; i++) {
Sheet s = wb.getSheet(crefs[i].getSheetName());
@ -1295,7 +1300,7 @@ Examples:
// Retrieve the cell at the named range and test its contents
// Will get back one AreaReference for C10, and
// another for D12 to D14
AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getReference());
AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula());
for (int i=0; i&lt;arefs.length; i++) {
// Only get the corners of the Area
// (use arefs[i].getAllReferencedCells() to get all cells)
@ -1320,7 +1325,7 @@ Examples:
if(name.isDeleted()){
//named range points to a deleted cell.
} else {
AreaReference ref = new AreaReference(name.getReference());
AreaReference ref = new AreaReference(name.getRefersToFormula());
}
</source>
</section>

View File

@ -267,38 +267,38 @@ public class LoanCalculator {
name = wb.createName();
name.setNameName("Interest_Rate");
name.setReference("'Loan Calculator'!$E$5");
name.setRefersToFormula("'Loan Calculator'!$E$5");
name = wb.createName();
name.setNameName("Loan_Amount");
name.setReference("'Loan Calculator'!$E$4");
name.setRefersToFormula("'Loan Calculator'!$E$4");
name = wb.createName();
name.setNameName("Loan_Start");
name.setReference("'Loan Calculator'!$E$7");
name.setRefersToFormula("'Loan Calculator'!$E$7");
name = wb.createName();
name.setNameName("Loan_Years");
name.setReference("'Loan Calculator'!$E$6");
name.setRefersToFormula("'Loan Calculator'!$E$6");
name = wb.createName();
name.setNameName("Number_of_Payments");
name.setReference("'Loan Calculator'!$E$10");
name.setRefersToFormula("'Loan Calculator'!$E$10");
name = wb.createName();
name.setNameName("Monthly_Payment");
name.setReference("-PMT(Interest_Rate/12,Number_of_Payments,Loan_Amount)");
name.setRefersToFormula("-PMT(Interest_Rate/12,Number_of_Payments,Loan_Amount)");
name = wb.createName();
name.setNameName("Total_Cost");
name.setReference("'Loan Calculator'!$E$12");
name.setRefersToFormula("'Loan Calculator'!$E$12");
name = wb.createName();
name.setNameName("Total_Interest");
name.setReference("'Loan Calculator'!$E$11");
name.setRefersToFormula("'Loan Calculator'!$E$11");
name = wb.createName();
name.setNameName("Values_Entered");
name.setReference("IF(Loan_Amount*Interest_Rate*Loan_Years*Loan_Start>0,1,0)");
name.setRefersToFormula("IF(Loan_Amount*Interest_Rate*Loan_Years*Loan_Start>0,1,0)");
}
}

View File

@ -62,8 +62,28 @@ public final class HSSFName implements Name {
}
/**
* sets the name of the named range
* Sets the name of the named range
*
* <p>The following is a list of syntax rules that you need to be aware of when you create and edit names.</p>
* <ul>
* <li><strong>Valid characters</strong>
* The first character of a name must be a letter, an underscore character (_), or a backslash (\).
* Remaining characters in the name can be letters, numbers, periods, and underscore characters.
* </li>
* <li><strong>Cell references disallowed</strong>
* Names cannot be the same as a cell reference, such as Z$100 or R1C1.</li>
* <li><strong>Spaces are not valid</strong>
* Spaces are not allowed as part of a name. Use the underscore character (_) and period (.) as word separators, such as, Sales_Tax or First.Quarter.
* </li>
* <li><strong>Name length</strong>
* A name can contain up to 255 characters.
* </li>
* <li><strong>Case sensitivity</strong>
* Names can contain uppercase and lowercase letters.
* </li>
* </ul>
* @param nameName named range name to set
* @throws IllegalArgumentException if the name is invalid or the workbook already contains this name (case-insensitive)
*/
public void setNameName(String nameName){
_definedNameRec.setNameText(nameName);
@ -81,29 +101,49 @@ public final class HSSFName implements Name {
}
/**
* @deprecated (Nov 2008) Misleading name. Use {@link #getFormula()} instead.
* Returns the formula that the name is defined to refer to.
*
* @deprecated (Nov 2008) Misleading name. Use {@link #getRefersToFormula()} instead.
*/
public String getReference() {
return getFormula();
return getRefersToFormula();
}
/**
* @deprecated (Nov 2008) Misleading name. Use {@link #setFormula(String)} instead.
* Sets the formula that the name is defined to refer to.
*
* @deprecated (Nov 2008) Misleading name. Use {@link #setRefersToFormula(String)} instead.
*/
public void setReference(String ref){
setFormula(ref);
setRefersToFormula(ref);
}
public void setFormula(String formulaText) {
/**
* Sets the formula that the name is defined to refer to. The following are representative examples:
*
* <ul>
* <li><code>'My Sheet'!$A$3</code></li>
* <li><code>8.3</code></li>
* <li><code>HR!$A$1:$Z$345</code></li>
* <li><code>SUM(Sheet1!A1,Sheet2!B2)</li>
* <li><code>-PMT(Interest_Rate/12,Number_of_Payments,Loan_Amount)</li>
* </ul>
*
* @param formulaText the reference for this name
* @throws IllegalArgumentException if the specified reference is unparsable
*/
public void setRefersToFormula(String formulaText) {
Ptg[] ptgs = HSSFFormulaParser.parse(formulaText, _book);
_definedNameRec.setNameDefinition(ptgs);
}
/**
* Note - this method only applies to named ranges
* @return the formula text defining this name
* Returns the formula that the name is defined to refer to. The following are representative examples:
*
* @return the reference for this name
* @see #setRefersToFormula(String)
*/
public String getFormula() {
public String getRefersToFormula() {
if (_definedNameRec.isFunctionName()) {
throw new IllegalStateException("Only applicable to named ranges");
}
@ -116,20 +156,19 @@ public final class HSSFName implements Name {
* @return true if the name refers to a deleted cell, false otherwise
*/
public boolean isDeleted(){
String formulaText = getReference();
if (formulaText.startsWith("#REF!")) {
// sheet deleted
return true;
}
if (formulaText.endsWith("#REF!")) {
// cell range deleted
return true;
}
return false;
String formulaText = getRefersToFormula();
return formulaText.indexOf("#REF!") != -1;
}
/**
* Checks if this name is a function name
*
* @return true if this name is a function name
*/
public boolean isFunctionName() {
return _definedNameRec.isFunctionName();
}
public String toString() {
StringBuffer sb = new StringBuffer(64);
sb.append(getClass().getName()).append(" [");

View File

@ -17,44 +17,105 @@
package org.apache.poi.ss.usermodel;
/**
* Represents a defined name for a range of cells.
* <p>
* A name is a meaningful shorthand that makes it easier to understand the purpose of a
* cell reference, constant or a formula.
* </p>
* Examples:
* <pre><blockquote>
* Sheet sheet = workbook.createSheet("Loan Calculator");
* Name name;
*
* name = workbook.createName();
* name.setNameName("Interest_Rate");
* name.setRefersToFormula("'Loan Calculator'!$E$5");
*
* name = wb.createName();
* name.setNameName("Loan_Amount");
* name.setRefersToFormula("'Loan Calculator'!$E$4");
*
* name = wb.createName();
* name.setNameName("Number_of_Payments");
* name.setRefersToFormula("'Loan Calculator'!$E$10");
*
* name = wb.createName();
* name.setNameName("Monthly_Payment");
* name.setRefersToFormula("-PMT(Interest_Rate/12,Number_of_Payments,Loan_Amount)");
*
* name = wb.createName();
* name.setNameName("Values_Entered");
* name.setRefersToFormula("IF(Loan_Amount*Interest_Rate>0,1,0)");
*
* </blockquote></pre>
*/
public interface Name {
/** Get the sheets name which this named range is referenced to
/**
* Get the sheets name which this named range is referenced to
*
* @return sheet name, which this named range refered to
*/
String getSheetName();
/**
* gets the name of the named range
* Gets the name of the named range
*
* @return named range name
*/
String getNameName();
/**
* sets the name of the named range
* @param nameName named range name to set
* Sets the name of the named range
*
* <p>The following is a list of syntax rules that you need to be aware of when you create and edit names.</p>
* <ul>
* <li><strong>Valid characters</strong>
* The first character of a name must be a letter, an underscore character (_), or a backslash (\).
* Remaining characters in the name can be letters, numbers, periods, and underscore characters.
* </li>
* <li><strong>Cell references disallowed</strong>
* Names cannot be the same as a cell reference, such as Z$100 or R1C1.</li>
* <li><strong>Spaces are not valid</strong>
* Spaces are not allowed as part of a name. Use the underscore character (_) and period (.) as word separators, such as, Sales_Tax or First.Quarter.
* </li>
* <li><strong>Name length</strong>
* A name can contain up to 255 characters.
* </li>
* <li><strong>Case sensitivity</strong>
* Names can contain uppercase and lowercase letters.
* </li>
* </ul>
* @param name named range name to set
* @throws IllegalArgumentException if the name is invalid or the workbook already contains this name (case-insensitive)
*/
void setNameName(String nameName);
void setNameName(String name);
/**
* @deprecated (Nov 2008) Misleading name. Use {@link #getFormula()} instead.
* Returns the formula that the name is defined to refer to. The following are representative examples:
*
* @return the reference for this name
* @see #setRefersToFormula(String)
*/
String getReference();
String getRefersToFormula();
/**
* @deprecated (Nov 2008) Misleading name. Use {@link #setFormula(String)} instead.
*/
void setReference(String ref);
/**
* @return the formula text defining this name
* Sets the formula that the name is defined to refer to. The following are representative examples:
*
* <ul>
* <li><code>'My Sheet'!$A$3</code></li>
* <li><code>8.3</code></li>
* <li><code>HR!$A$1:$Z$345</code></li>
* <li><code>SUM(Sheet1!A1,Sheet2!B2)</li>
* <li><code>-PMT(Interest_Rate/12,Number_of_Payments,Loan_Amount)</li>
* </ul>
*
* @param ref the reference for this name
* @throws IllegalArgumentException if the specified reference is unparsable
*/
String getFormula();
/**
* Sets the formula text defining this name
*/
void setFormula(String formulaText);
void setRefersToFormula(String ref);
/**
* Checks if this name is a function name
*

View File

@ -233,7 +233,7 @@ public interface Sheet extends Iterable<Row> {
*
* @param value <code>true</code> if the sheet displays Automatic Page Breaks.
*/
void setAutobreaks(boolean b);
void setAutobreaks(boolean value);
/**
* Set whether to display the guts or not

View File

@ -152,7 +152,7 @@ public final class XSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E
public Ptg[] getNameDefinition() {
return FormulaParser.parse(_nameRecord.getReference(), _fpBook);
return FormulaParser.parse(_nameRecord.getRefersToFormula(), _fpBook);
}
public String getNameText() {

View File

@ -37,14 +37,14 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedName;
* //applies to the entire workbook
* XSSFName name1 = wb.createName();
* name1.setNameName("FMLA");
* name1.setReference("Sheet1!$B$3");
* name1.setRefersToFormula("Sheet1!$B$3");
*
* //applies to Sheet1
* XSSFName name2 = wb.createName();
* name2.setNameName("SheetLevelName");
* name2.setComment("This name is scoped to Sheet1");
* name2.setLocalSheetId(0);
* name2.setReference("Sheet1!$B$3");
* name2.setRefersToFormula("Sheet1!$B$3");
*
* </blockquote></pre>
*
@ -153,25 +153,12 @@ public final class XSSFName implements Name {
ctName.setName(name);
}
/**
* @deprecated (Nov 2008) Misleading name. Use {@link #getFormula()} instead.
*/
public String getReference() {
return getFormula();
}
/**
* @deprecated (Nov 2008) Misleading name. Use {@link #setFormula(String)} instead.
*/
public void setReference(String ref){
setFormula(ref);
}
/**
* Returns the reference of this named range, such as Sales!C20:C30.
*
* @return the reference of this named range
*/
public String getFormula() {
public String getRefersToFormula() {
return ctName.getStringValue();
}
@ -181,7 +168,7 @@ public final class XSSFName implements Name {
* @param formulaText the reference to set
* @throws IllegalArgumentException if the specified reference is unparsable
*/
public void setFormula(String formulaText) {
public void setRefersToFormula(String formulaText) {
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(workbook);
Ptg[] ptgs;
try {
@ -201,7 +188,7 @@ public final class XSSFName implements Name {
* @return true if the name refers to a deleted cell, false otherwise
*/
public boolean isDeleted(){
String ref = getReference();
String ref = getRefersToFormula();
return ref != null && ref.indexOf("#REF!") != -1;
}
@ -278,7 +265,7 @@ public final class XSSFName implements Name {
int sheetId = (int)ctName.getLocalSheetId();
return workbook.getSheetName(sheetId);
} else {
String ref = getReference();
String ref = getRefersToFormula();
AreaReference areaRef = new AreaReference(ref);
return areaRef.getFirstCell().getSheetName();
}

View File

@ -617,7 +617,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
XSSFName name = getBuiltInName(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
if (name == null) return null;
//adding one here because 0 indicates a global named region; doesnt make sense for print areas
return name.getReference();
return name.getRefersToFormula();
}
@ -871,7 +871,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
sb.append("!");
sb.append(parts[i]);
}
name.setFormula(sb.toString());
name.setRefersToFormula(sb.toString());
}
/**
@ -931,7 +931,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
if (name == null) {
name = createBuiltInName(XSSFName.BUILTIN_PRINT_TITLE, sheetIndex);
String reference = getReferenceBuiltInRecord(name.getSheetName(), startColumn, endColumn, startRow, endRow);
name.setReference(reference);
name.setRefersToFormula(reference);
namedRanges.add(name);
}

View File

@ -657,7 +657,7 @@ public class XWPFParagraph {
* Specifies the spacing that should be added above the first line in this
* paragraph in the document in absolute units.
*
* @return
* @return the spacing that should be added above the first line
* @see #setSpacingBefore(BigInteger)
*/
public BigInteger getSpacingBefore() {
@ -687,7 +687,7 @@ public class XWPFParagraph {
* document in line units.
* The value of this attribute is specified in one hundredths of a line.
*
* @return
* @return the spacing that should be added before the first line in this paragraph
* @see #setSpacingBeforeLines(BigInteger)
*/
public BigInteger getSpacingBeforeLines() {

View File

@ -48,23 +48,23 @@ public class TestXSSFBugs extends TestCase {
assertEquals(0, wb.getNameAt(0).getCTName().getLocalSheetId());
assertFalse(wb.getNameAt(0).getCTName().isSetLocalSheetId());
assertEquals("SheetA!$A$1", wb.getNameAt(0).getReference());
assertEquals("SheetA!$A$1", wb.getNameAt(0).getRefersToFormula());
assertEquals("SheetA", wb.getNameAt(0).getSheetName());
assertEquals(0, wb.getNameAt(1).getCTName().getLocalSheetId());
assertFalse(wb.getNameAt(1).getCTName().isSetLocalSheetId());
assertEquals("SheetB!$A$1", wb.getNameAt(1).getReference());
assertEquals("SheetB!$A$1", wb.getNameAt(1).getRefersToFormula());
assertEquals("SheetB", wb.getNameAt(1).getSheetName());
assertEquals(0, wb.getNameAt(2).getCTName().getLocalSheetId());
assertFalse(wb.getNameAt(2).getCTName().isSetLocalSheetId());
assertEquals("SheetC!$A$1", wb.getNameAt(2).getReference());
assertEquals("SheetC!$A$1", wb.getNameAt(2).getRefersToFormula());
assertEquals("SheetC", wb.getNameAt(2).getSheetName());
// Save and re-load, still there
XSSFWorkbook nwb = XSSFTestDataSamples.writeOutAndReadBack(wb);
assertEquals(3, nwb.getNumberOfNames());
assertEquals("SheetA!$A$1", nwb.getNameAt(0).getReference());
assertEquals("SheetA!$A$1", nwb.getNameAt(0).getRefersToFormula());
}
/**

View File

@ -43,14 +43,13 @@ public class TestXSSFName extends TestCase {
name2.setNameName("testTwo");
String ref1 = "Test1!$A$1:$B$1";
name1.setReference(ref1);
assertEquals(ref1, name1.getReference());
name1.setRefersToFormula(ref1);
assertEquals(ref1, name1.getRefersToFormula());
assertEquals("Test1", name1.getSheetName());
String ref2 = "'Testing Named Ranges'!$A$1:$B$1";
name1.setReference(ref2);
//XSSFName#setReference stores the reference in canonical form and puts the sheet name in single quotes
assertEquals("'Testing Named Ranges'!$A$1:$B$1", name1.getReference());
name1.setRefersToFormula(ref2);
assertEquals("'Testing Named Ranges'!$A$1:$B$1", name1.getRefersToFormula());
assertEquals("Testing Named Ranges", name1.getSheetName());
assertEquals(-1, name1.getLocalSheetId());
@ -63,14 +62,14 @@ public class TestXSSFName extends TestCase {
workBook.createSheet("Test");
XSSFName name = workBook.createName();
name.setNameName("\u03B1");
name.setReference("Test!$D$3:$E$8");
name.setRefersToFormula("Test!$D$3:$E$8");
XSSFWorkbook workBook2 = XSSFTestDataSamples.writeOutAndReadBack(workBook);
XSSFName name2 = workBook2.getNameAt(0);
assertEquals("\u03B1", name2.getNameName());
assertEquals("Test!$D$3:$E$8", name2.getReference());
assertEquals("Test!$D$3:$E$8", name2.getRefersToFormula());
}
public void testAddRemove() {

View File

@ -183,7 +183,7 @@ public final class TestXSSFWorkbook extends TestCase {
XSSFName nr1 = wb.getNameAt(0);
assertEquals(XSSFName.BUILTIN_PRINT_TITLE, nr1.getNameName());
assertEquals("'FirstSheet'!$A:$A,'FirstSheet'!$1:$4", nr1.getReference());
assertEquals("'FirstSheet'!$A:$A,'FirstSheet'!$1:$4", nr1.getRefersToFormula());
// Save and re-open
XSSFWorkbook nwb = XSSFTestDataSamples.writeOutAndReadBack(wb);
@ -192,7 +192,7 @@ public final class TestXSSFWorkbook extends TestCase {
nr1 = nwb.getNameAt(0);
assertEquals(XSSFName.BUILTIN_PRINT_TITLE, nr1.getNameName());
assertEquals("'FirstSheet'!$A:$A,'FirstSheet'!$1:$4", nr1.getReference());
assertEquals("'FirstSheet'!$A:$A,'FirstSheet'!$1:$4", nr1.getRefersToFormula());
// check that setting RR&C on a second sheet causes a new Print_Titles built-in
// name to be created
@ -203,7 +203,7 @@ public final class TestXSSFWorkbook extends TestCase {
XSSFName nr2 = nwb.getNameAt(1);
assertEquals(XSSFName.BUILTIN_PRINT_TITLE, nr2.getNameName());
assertEquals("'SecondSheet'!$B:$C,'SecondSheet'!$1:$1", nr2.getReference());
assertEquals("'SecondSheet'!$B:$C,'SecondSheet'!$1:$1", nr2.getRefersToFormula());
nwb.setRepeatingRowsAndColumns(1, -1, -1, -1, -1);
@ -464,11 +464,11 @@ public final class TestXSSFWorkbook extends TestCase {
assertEquals(0, workbook.getNumberOfNames());
Name nameA = workbook.createName();
nameA.setReference("A2");
nameA.setRefersToFormula("A2");
nameA.setNameName("ForA2");
XSSFName nameB = workbook.createName();
nameB.setReference("B3");
nameB.setRefersToFormula("B3");
nameB.setNameName("ForB3");
nameB.setComment("B3 Comment");
@ -476,11 +476,11 @@ public final class TestXSSFWorkbook extends TestCase {
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
assertEquals(2, workbook.getNumberOfNames());
assertEquals("A2", workbook.getNameAt(0).getReference());
assertEquals("A2", workbook.getNameAt(0).getRefersToFormula());
assertEquals("ForA2", workbook.getNameAt(0).getNameName());
assertNull(workbook.getNameAt(0).getComment());
assertEquals("B3", workbook.getNameAt(1).getReference());
assertEquals("B3", workbook.getNameAt(1).getRefersToFormula());
assertEquals("ForB3", workbook.getNameAt(1).getNameName());
assertEquals("B3 Comment", workbook.getNameAt(1).getComment());
@ -493,11 +493,11 @@ public final class TestXSSFWorkbook extends TestCase {
workbook = XSSFTestDataSamples.openSampleWorkbook("WithVariousData.xlsx");
assertEquals(2, workbook.getNumberOfNames());
assertEquals("Sheet1!$A$2:$A$7", workbook.getNameAt(0).getReference());
assertEquals("Sheet1!$A$2:$A$7", workbook.getNameAt(0).getRefersToFormula());
assertEquals("AllANumbers", workbook.getNameAt(0).getNameName());
assertEquals("All the numbers in A", workbook.getNameAt(0).getComment());
assertEquals("Sheet1!$B$2:$B$7", workbook.getNameAt(1).getReference());
assertEquals("Sheet1!$B$2:$B$7", workbook.getNameAt(1).getRefersToFormula());
assertEquals("AllBStrings", workbook.getNameAt(1).getNameName());
assertEquals("All the strings in B", workbook.getNameAt(1).getComment());
@ -507,11 +507,11 @@ public final class TestXSSFWorkbook extends TestCase {
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
assertEquals(2, workbook.getNumberOfNames());
assertEquals("Sheet1!$A$2:$A$7", workbook.getNameAt(0).getReference());
assertEquals("Sheet1!$A$2:$A$7", workbook.getNameAt(0).getRefersToFormula());
assertEquals("AllANumbers", workbook.getNameAt(0).getNameName());
assertEquals("All the numbers in A", workbook.getNameAt(0).getComment());
assertEquals("Sheet1!$B$2:$B$7", workbook.getNameAt(1).getReference());
assertEquals("Sheet1!$B$2:$B$7", workbook.getNameAt(1).getRefersToFormula());
assertEquals("BStringsFun", workbook.getNameAt(1).getNameName());
assertEquals("All the strings in B", workbook.getNameAt(1).getComment());
}

View File

@ -825,7 +825,7 @@ public final class TestFormulaParser extends TestCase {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Sheet1");
HSSFName name = wb.createName();
name.setFormula("Sheet1!B1");
name.setRefersToFormula("Sheet1!B1");
name.setNameName("pfy1");
Ptg[] ptgs;

View File

@ -76,9 +76,9 @@ public final class TestNameRecord extends TestCase {
HSSFName name = wb.createName();
wb.createSheet("Sheet1");
name.setNameName("test");
name.setFormula("Sheet1!A1+Sheet1!A2");
assertEquals("Sheet1!A1+Sheet1!A2", name.getFormula());
name.setFormula("5*6");
assertEquals("5*6", name.getFormula());
name.setRefersToFormula("Sheet1!A1+Sheet1!A2");
assertEquals("Sheet1!A1+Sheet1!A2", name.getRefersToFormula());
name.setRefersToFormula("5*6");
assertEquals("5*6", name.getRefersToFormula());
}
}