View | Details | Raw Unified | Return to bug 44892
Collapse All | Expand All

(-)C:\josh\client\poi\svn\trunk-h2/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (-3 / +5 lines)
Lines 600-605 Link Here
600
     *
600
     *
601
     * @param sheetname     sheetname to set for the sheet.
601
     * @param sheetname     sheetname to set for the sheet.
602
     * @return HSSFSheet representing the new sheet.
602
     * @return HSSFSheet representing the new sheet.
603
     * @throws IllegalArgumentException if there is already a sheet present with a case-insensitive
604
     *  match to the specified name.
603
     */
605
     */
604
606
605
    public HSSFSheet createSheet(String sheetname)
607
    public HSSFSheet createSheet(String sheetname)
Lines 639-647 Link Here
639
    }
641
    }
640
642
641
    /**
643
    /**
642
     * Get sheet with the given name
644
     * Get sheet with the given name (case insensitive match)
643
     * @param name of the sheet
645
     * @param name of the sheet
644
     * @return HSSFSheet with the name provided or null if it does not exist
646
     * @return HSSFSheet with the name provided or <code>null</code> if it does not exist
645
     */
647
     */
646
648
647
    public HSSFSheet getSheet(String name)
649
    public HSSFSheet getSheet(String name)
Lines 652-658 Link Here
652
        {
654
        {
653
            String sheetname = workbook.getSheetName(k);
655
            String sheetname = workbook.getSheetName(k);
654
656
655
            if (sheetname.equals(name))
657
            if (sheetname.equalsIgnoreCase(name))
656
            {
658
            {
657
                retval = (HSSFSheet) sheets.get(k);
659
                retval = (HSSFSheet) sheets.get(k);
658
            }
660
            }
(-)C:\josh\client\poi\svn\trunk-h2/src/java/org/apache/poi/hssf/model/Workbook.java (-3 / +3 lines)
Lines 476-484 Link Here
476
    }
476
    }
477
477
478
    /**
478
    /**
479
     * Determines whether a workbook contains the privided sheet name.
479
     * Determines whether a workbook contains the provided sheet name.
480
     *
480
     *
481
     * @param name the name to test
481
     * @param name the name to test (case insensitive match)
482
     * @param excludeSheetIdx the sheet to exclude from the check or -1 to include all sheets in the check.
482
     * @param excludeSheetIdx the sheet to exclude from the check or -1 to include all sheets in the check.
483
     * @return true if the sheet contains the name, false otherwise.
483
     * @return true if the sheet contains the name, false otherwise.
484
     */
484
     */
Lines 487-493 Link Here
487
        for ( int i = 0; i < boundsheets.size(); i++ )
487
        for ( int i = 0; i < boundsheets.size(); i++ )
488
        {
488
        {
489
            BoundSheetRecord boundSheetRecord = (BoundSheetRecord) boundsheets.get( i );
489
            BoundSheetRecord boundSheetRecord = (BoundSheetRecord) boundsheets.get( i );
490
            if (excludeSheetIdx != i && name.equals(boundSheetRecord.getSheetname()))
490
            if (excludeSheetIdx != i && name.equalsIgnoreCase(boundSheetRecord.getSheetname()))
491
                return true;
491
                return true;
492
        }
492
        }
493
        return false;
493
        return false;
(-)C:\josh\client\poi\svn\trunk-h2/src/documentation/content/xdocs/changes.xml (+1 lines)
Lines 37-42 Link Here
37
37
38
		<!-- Don't forget to update status.xml too! -->
38
		<!-- Don't forget to update status.xml too! -->
39
        <release version="3.1-beta1" date="2008-04-??">
39
        <release version="3.1-beta1" date="2008-04-??">
40
           <action dev="POI-DEVELOPERS" type="fix">44892 - made HSSFWorkbook.getSheet(String) case insensitive</action>
40
           <action dev="POI-DEVELOPERS" type="fix">44857 - Avoid OOM on unknown escher records when EscherMetafileBlip is incorrect</action>
41
           <action dev="POI-DEVELOPERS" type="fix">44857 - Avoid OOM on unknown escher records when EscherMetafileBlip is incorrect</action>
41
           <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting embedded sounds from slide show </action>
42
           <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting embedded sounds from slide show </action>
42
           <action dev="POI-DEVELOPERS" type="add">HSLF: Initial support for rendering slides into images</action>
43
           <action dev="POI-DEVELOPERS" type="add">HSLF: Initial support for rendering slides into images</action>
(-)C:\josh\client\poi\svn\trunk-h2/src/documentation/content/xdocs/status.xml (+1 lines)
Lines 34-39 Link Here
34
	<!-- Don't forget to update changes.xml too! -->
34
	<!-- Don't forget to update changes.xml too! -->
35
    <changes>
35
    <changes>
36
        <release version="3.1-beta1" date="2008-04-??">
36
        <release version="3.1-beta1" date="2008-04-??">
37
           <action dev="POI-DEVELOPERS" type="fix">44892 - made HSSFWorkbook.getSheet(String) case insensitive</action>
37
           <action dev="POI-DEVELOPERS" type="fix">44857 - Avoid OOM on unknown escher records when EscherMetafileBlip is incorrect</action>
38
           <action dev="POI-DEVELOPERS" type="fix">44857 - Avoid OOM on unknown escher records when EscherMetafileBlip is incorrect</action>
38
           <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting embedded sounds from slide show </action>
39
           <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting embedded sounds from slide show </action>
39
           <action dev="POI-DEVELOPERS" type="add">HSLF: Initial support for rendering slides into images</action>
40
           <action dev="POI-DEVELOPERS" type="add">HSLF: Initial support for rendering slides into images</action>
(-)C:\josh\client\poi\svn\trunk-h2/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java (-1 / +19 lines)
Lines 17-22 Link Here
17
17
18
package org.apache.poi.hssf.usermodel;
18
package org.apache.poi.hssf.usermodel;
19
19
20
import junit.framework.AssertionFailedError;
20
import junit.framework.TestCase;
21
import junit.framework.TestCase;
21
22
22
import org.apache.poi.hssf.HSSFTestDataSamples;
23
import org.apache.poi.hssf.HSSFTestDataSamples;
Lines 39-45 Link Here
39
        NameRecord nameRecord = b.getWorkbook().getNameRecord( 0 );
40
        NameRecord nameRecord = b.getWorkbook().getNameRecord( 0 );
40
        assertEquals( 3, nameRecord.getIndexToSheet() );
41
        assertEquals( 3, nameRecord.getIndexToSheet() );
41
    }
42
    }
42
    
43
44
    public void testCaseInsensitiveNames() {
45
        HSSFWorkbook b = new HSSFWorkbook( );
46
        HSSFSheet originalSheet = b.createSheet("Sheet1");
47
        HSSFSheet fetchedSheet = b.getSheet("sheet1");
48
        if(fetchedSheet == null) {
49
            throw new AssertionFailedError("Identified bug 44892");
50
        }
51
        assertEquals(originalSheet, fetchedSheet);
52
        try {
53
            b.createSheet("sHeeT1");
54
            fail("should have thrown exceptiuon due to duplicate sheet name");
55
        } catch (IllegalArgumentException e) {
56
            // expected during successful test
57
            assertEquals("The workbook already contains a sheet of this name", e.getMessage());
58
        }
59
    }
60
43
    public void testDuplicateNames() {
61
    public void testDuplicateNames() {
44
        HSSFWorkbook b = new HSSFWorkbook( );
62
        HSSFWorkbook b = new HSSFWorkbook( );
45
        b.createSheet("Sheet1");
63
        b.createSheet("Sheet1");

Return to bug 44892