1 2 17 18 19 package org.apache.poi.hssf.usermodel; 20 21 import java.io.File ; 22 import java.io.FileInputStream ; 23 import java.io.FileOutputStream ; 24 25 import junit.framework.TestCase; 26 27 import org.apache.poi.hssf.util.Region; 28 import org.apache.poi.poifs.filesystem.POIFSFileSystem; 29 30 36 public class TestCloneSheet extends TestCase { 37 38 public TestCloneSheet(String arg0) { 39 super(arg0); 40 } 41 42 public void testCloneSheetBasic(){ 43 try{ 44 HSSFWorkbook b = new HSSFWorkbook(); 45 HSSFSheet s = b.createSheet("Test"); 46 s.addMergedRegion(new Region((short)0,(short)0,(short)1,(short)1)); 47 HSSFSheet clonedSheet = b.cloneSheet(0); 48 49 assertEquals("One merged area", 1, clonedSheet.getNumMergedRegions()); 50 51 } 52 catch(Exception e){e.printStackTrace();fail(e.getMessage());} 53 } 54 55 59 public void testPageBreakClones() { 60 HSSFWorkbook b = new HSSFWorkbook(); 61 HSSFSheet s = b.createSheet("Test"); 62 s.setRowBreak(3); 63 s.setColumnBreak((short)6); 64 65 HSSFSheet clone = b.cloneSheet(0); 66 assertTrue("Row 3 not broken", clone.isRowBroken(3)); 67 assertTrue("Column 6 not broken", clone.isColumnBroken((short)6)); 68 69 s.removeRowBreak(3); 70 71 assertTrue("Row 3 still should be broken", clone.isRowBroken(3)); 72 } 73 74 } 75 | Popular Tags |