Package org.apache.poi.hssf.usermodel

Examples of org.apache.poi.hssf.usermodel.HSSFHeader


        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());
    }
View Full Code Here


       
       
        // Create Excel Workbook and Sheet
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet(filename);
        HSSFHeader header = sheet.getHeader();
        header.setCenter(filename);
       
       
        //Setup the output
        String contentType = "application/vnd.ms-excel";
        FacesContext fc = FacesContext.getCurrentInstance();
View Full Code Here

        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());
    }
View Full Code Here

   * Testcase for Bug 17039 HSSFHeader  doesnot support DBCS
   */
  public void testHeaderHas16bitCharacter() throws Exception {
      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");
  }
View Full Code Here

  public void testReadDBCSHeaderFooter() throws Exception{
    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");
View Full Code Here

        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());
    }
View Full Code Here

   * Testcase for Bug 17039 HSSFHeader  doesnot support DBCS
   */
  public void testHeaderHas16bitCharacter() throws Exception {
      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");
  }
View Full Code Here

  public void testReadDBCSHeaderFooter() throws Exception{
    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");
View Full Code Here

                    emptyCell = row.createCell(x);
                    emptyCell.setCellStyle(emptyCellStyle);
                }
            }
        }
        HSSFHeader xlsHeader = xlsSheet.getHeader();
        HSSFFooter xlsFooter = xlsSheet.getFooter();

        if (StringUtil.stNul(leftHeader) != null) {
            xlsHeader.setLeft(StringUtil.stNul(leftHeader));
        }
        if (StringUtil.stNul(centerHeader) != null) {
            xlsHeader.setCenter(leftHeader);
            try {
                if (centerHeader.length() >= 254) {
                    centerHeader = centerHeader.substring(0, 254);
                }
                xlsHeader.setCenter(centerHeader);
            } catch (Exception e) {
                logger.log(Level.INFO, "Header string is too large.");
            }

        }
        if (StringUtil.stNul(rightHeader) != null) {
            xlsHeader.setRight(StringUtil.stNul(rightHeader));
        }
        if (StringUtil.stNul(leftFooter) != null) {
            xlsFooter.setLeft(StringUtil.stNul(leftFooter));
        }
        if (StringUtil.stNul(centerFooter) != null) {
View Full Code Here

   
    /**
     * Set text to be printed at the top of every page
     */
    void setHeader(String left, String middle, String right) {
        HSSFHeader header = _sheet.getHeader();
        header.setLeft(left);
        header.setCenter(middle);
        header.setRight(right);
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.usermodel.HSSFHeader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.