]> source.dussan.org Git - poi.git/commitdiff
Sheet naming checks caused a test failure in cloneSheet.
authorAvik Sengupta <avik@apache.org>
Mon, 13 Oct 2003 16:45:01 +0000 (16:45 +0000)
committerAvik Sengupta <avik@apache.org>
Mon, 13 Oct 2003 16:45:01 +0000 (16:45 +0000)
CloneSheet used an invalid character, which we now dont allow! Corrected.
Good thing we have tests!!

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/REL_2_BRANCH@353393 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
src/testcases/org/apache/poi/hssf/usermodel/TestCloneSheet.java

index 058e60c7d3e9777055b90abe5e38bb49258ec7aa..c1bfbd318214b4b39346af99375d435ca295bc3a 100644 (file)
@@ -384,7 +384,11 @@ public class HSSFWorkbook
         windowTwo.setPaged(sheets.size() == 1);
 
         sheets.add(clonedSheet);
-        workbook.setSheetName(sheets.size()-1, srcName+"[1]");
+        if (srcName.length()<28) {
+            workbook.setSheetName(sheets.size()-1, srcName+"(2)");
+        }else {
+            workbook.setSheetName(sheets.size()-1,srcName.substring(0,28)+"(2)");
+        }
         return clonedSheet;
       }
       return null;
index 052516108c968dda9783bb2deeac625e244dcacd..6ccf29ec2719cccec5bf3ca502d69f2ebe8ed5c5 100644 (file)
@@ -79,7 +79,7 @@ public class TestCloneSheet extends TestCase {
                        s.addMergedRegion(new Region((short)0,(short)0,(short)1,(short)1));
                        b.cloneSheet(0);
                }
-               catch(Exception e){fail(e.getMessage());}
+               catch(Exception e){e.printStackTrace();fail(e.getMessage());}
        }
 
 }