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:
parent
c8bcb1569c
commit
9788ef65f0
@ -365,7 +365,7 @@ public class HSSFWorkbook
|
|||||||
|
|
||||||
public HSSFSheet createSheet(String sheetname)
|
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" );
|
throw new IllegalArgumentException( "The workbook already contains a sheet of this name" );
|
||||||
|
|
||||||
HSSFSheet sheet = new HSSFSheet(workbook);
|
HSSFSheet sheet = new HSSFSheet(workbook);
|
||||||
|
@ -23,7 +23,7 @@ public class TestHSSFWorkbook extends TestCase
|
|||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
HSSFWorkbook b = new HSSFWorkbook( );
|
HSSFWorkbook b = new HSSFWorkbook( );
|
||||||
b.createSheet();
|
b.createSheet("Sheet1");
|
||||||
b.createSheet();
|
b.createSheet();
|
||||||
b.createSheet("name1");
|
b.createSheet("name1");
|
||||||
try
|
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.ENCODING_UTF_16 );
|
b.setSheetName( 3, "name2", HSSFWorkbook.ENCODING_UTF_16 );
|
||||||
b.setSheetName( 3, "name2" );
|
b.setSheetName( 3, "name2" );
|
||||||
|
|
||||||
|
HSSFWorkbook c = new HSSFWorkbook( );
|
||||||
|
c.createSheet("Sheet1");
|
||||||
|
c.createSheet("Sheet2");
|
||||||
|
c.createSheet("Sheet3");
|
||||||
|
c.createSheet("Sheet4");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user