fix for not being able to name a sheet as Sheet1, with some tests

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353639 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Avik Sengupta 2005-04-21 07:43:22 +00:00
parent c8bcb1569c
commit 9788ef65f0
2 changed files with 8 additions and 2 deletions

View File

@ -365,7 +365,7 @@ public class HSSFWorkbook
public HSSFSheet createSheet(String sheetname)
{
if (workbook.doesContainsSheetName( sheetname, -1 ))
if (workbook.doesContainsSheetName( sheetname, sheets.size() ))
throw new IllegalArgumentException( "The workbook already contains a sheet of this name" );
HSSFSheet sheet = new HSSFSheet(workbook);

View File

@ -23,7 +23,7 @@ public class TestHSSFWorkbook extends TestCase
throws Exception
{
HSSFWorkbook b = new HSSFWorkbook( );
b.createSheet();
b.createSheet("Sheet1");
b.createSheet();
b.createSheet("name1");
try
@ -56,6 +56,12 @@ public class TestHSSFWorkbook extends TestCase
b.setSheetName( 3, "name2", HSSFWorkbook.ENCODING_UTF_16 );
b.setSheetName( 3, "name2", HSSFWorkbook.ENCODING_UTF_16 );
b.setSheetName( 3, "name2" );
HSSFWorkbook c = new HSSFWorkbook( );
c.createSheet("Sheet1");
c.createSheet("Sheet2");
c.createSheet("Sheet3");
c.createSheet("Sheet4");
}
}