FileDocCategorySizeDatePackage
TestHSSFHeaderFooter.javaAPI DocApache Poi 3.0.15305Mon Jan 01 12:39:46 GMT 2007org.apache.poi.hssf.usermodel

TestHSSFHeaderFooter

public class TestHSSFHeaderFooter extends TestCase
Tests row shifting capabilities.
author
Shawn Laubach (slaubach at apache dot com)

Fields Summary
Constructors Summary
public TestHSSFHeaderFooter(String arg0)
Constructor for TestHeaderFooter.

param
arg0

	super(arg0);
    
Methods Summary
public voidtestFooterHas16bitCharacter()
Testcase for Bug 17039 HSSFFooter doesnot support DBCS

			HSSFWorkbook b = new HSSFWorkbook();
			HSSFSheet s = b.createSheet("Test");
			HSSFFooter f = s.getFooter();
			f.setLeft("\u0391");
			f.setCenter("\u0392");
			f.setRight("\u0393");
			
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			b.write(out);
			
			HSSFWorkbook b2 = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray()));
			HSSFFooter f2 = b2.getSheet("Test").getFooter();
			
			assertEquals(f2.getLeft(),"\u0391");
			assertEquals(f2.getCenter(),"\u0392");
			assertEquals(f2.getRight(),"\u0393");
	
public voidtestHeaderHas16bitCharacter()
Testcase for Bug 17039 HSSFHeader doesnot support DBCS

			HSSFWorkbook b = new HSSFWorkbook();
			HSSFSheet s = b.createSheet("Test");
			HSSFHeader h = s.getHeader();
			h.setLeft("\u0391");
			h.setCenter("\u0392");
			h.setRight("\u0393");
			
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			b.write(out);
			
			HSSFWorkbook b2 = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray()));
			HSSFHeader h2 = b2.getSheet("Test").getHeader();
			
			assertEquals(h2.getLeft(),"\u0391");
			assertEquals(h2.getCenter(),"\u0392");
			assertEquals(h2.getRight(),"\u0393");
	
public voidtestReadDBCSHeaderFooter()

		String readFilename = System.getProperty("HSSF.testdata.path");
        FileInputStream in = new FileInputStream(readFilename+File.separator+"DBCSHeader.xls");
        HSSFWorkbook wb = new HSSFWorkbook(in);
        HSSFSheet s = wb.getSheetAt(0);
        HSSFHeader h = s.getHeader();
        assertEquals("Header Left " ,h.getLeft(),"\u090f\u0915");
        assertEquals("Header Center " ,h.getCenter(),"\u0939\u094b\u0917\u093e");
        assertEquals("Header Right " ,h.getRight(),"\u091c\u093e");
		
        HSSFFooter f = s.getFooter();
        assertEquals("Footer Left " ,f.getLeft(),"\u091c\u093e");
        assertEquals("Footer Center " ,f.getCenter(),"\u091c\u093e");
        assertEquals("Footer Right " ,f.getRight(),"\u091c\u093e");
	
public voidtestRetrieveCorrectFooter()
Tests that get header retreives the proper values.

author
Shawn Laubach (slaubach at apache dot org)

        // Read initial file in
        String filename = System.getProperty( "HSSF.testdata.path" );
        filename = filename + "/EmbeddedChartHeaderTest.xls";
        FileInputStream fin = new FileInputStream( filename );
        HSSFWorkbook wb = new HSSFWorkbook( fin );
        fin.close();
        HSSFSheet s = wb.getSheetAt( 0 );
	HSSFFooter foot = s.getFooter();

	assertEquals("Bottom Left", foot.getLeft());
	assertEquals("Bottom Center", foot.getCenter());
	assertEquals("Bottom Right", foot.getRight());
    
public voidtestRetrieveCorrectHeader()
Tests that get header retreives the proper values.

author
Shawn Laubach (slaubach at apache dot org)

        // Read initial file in
        String filename = System.getProperty( "HSSF.testdata.path" );
        filename = filename + "/EmbeddedChartHeaderTest.xls";
        FileInputStream fin = new FileInputStream( filename );
        HSSFWorkbook wb = new HSSFWorkbook( fin );
        fin.close();
        HSSFSheet s = wb.getSheetAt( 0 );
	HSSFHeader head = s.getHeader();

	assertEquals("Top Left", head.getLeft());
	assertEquals("Top Center", head.getCenter());
	assertEquals("Top Right", head.getRight());