KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > usermodel > TestHSSFWorkbook


1 package org.apache.poi.hssf.usermodel;
2
3 import junit.framework.*;
4 import org.apache.poi.hssf.record.NameRecord;
5
6 public class TestHSSFWorkbook extends TestCase
7 {
8     HSSFWorkbook hssfWorkbook;
9
10     public void testSetRepeatingRowsAndColumns() throws Exception JavaDoc
11     {
12         // Test bug 29747
13
HSSFWorkbook b = new HSSFWorkbook( );
14         b.createSheet();
15         b.createSheet();
16         b.createSheet();
17         b.setRepeatingRowsAndColumns( 2, 0,1,-1,-1 );
18         NameRecord nameRecord = b.getWorkbook().getNameRecord( 0 );
19         assertEquals( 3, nameRecord.getIndexToSheet() );
20     }
21
22     public void testDuplicateNames()
23             throws Exception JavaDoc
24     {
25         HSSFWorkbook b = new HSSFWorkbook( );
26         b.createSheet();
27         b.createSheet();
28         b.createSheet("name1");
29         try
30         {
31             b.createSheet("name1");
32             fail();
33         }
34         catch ( IllegalArgumentException JavaDoc pass )
35         {
36         }
37         b.createSheet();
38         try
39         {
40             b.setSheetName( 3, "name1" );
41             fail();
42         }
43         catch ( IllegalArgumentException JavaDoc pass )
44         {
45         }
46
47         try
48         {
49             b.setSheetName( 3, "name1", HSSFWorkbook.ENCODING_UTF_16 );
50             fail();
51         }
52         catch ( IllegalArgumentException JavaDoc pass )
53         {
54         }
55
56         b.setSheetName( 3, "name2", HSSFWorkbook.ENCODING_UTF_16 );
57         b.setSheetName( 3, "name2", HSSFWorkbook.ENCODING_UTF_16 );
58         b.setSheetName( 3, "name2" );
59
60     }
61 }
Popular Tags