Package org.apache.poi.hssf.usermodel

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


      }
      throw e;
    }
    assertEquals("test\"ing", sp.getValue());

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();
    wb.setSheetName(0, "Sheet1");

    HSSFRow row = sheet.createRow(0);
    HSSFCell cell = row.createCell((short)0);
    cell.setCellFormula("right(\"test\"\"ing\", 3)");
    String actualCellFormula = cell.getCellFormula();
View Full Code Here


    }
  }

  public void testSetFormulaWithRowBeyond32768_Bug44539() {

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();
    wb.setSheetName(0, "Sheet1");

    HSSFRow row = sheet.createRow(0);
    HSSFCell cell = row.createCell((short)0);
    cell.setCellFormula("SUM(A32769:A32770)");
    if("SUM(A-32767:A-32766)".equals(cell.getCellFormula())) {
View Full Code Here

    confirmArgCountMsg("index(1, 2, 3, 4, 5, 6)", "Too many arguments to function 'INDEX'. At most 4 were expected but got 6.");
    confirmArgCountMsg("vlookup(1, 2)", "Too few arguments to function 'VLOOKUP'. At least 3 were expected but got 2.");
  }

  private static void confirmArgCountMsg(String formula, String expectedMessage) {
    HSSFWorkbook book = new HSSFWorkbook();
    try {
      FormulaParser.parse(formula, book);
      throw new AssertionFailedError("Didn't get parse exception as expected");
    } catch (FormulaParseException e) {
      assertEquals(expectedMessage, e.getMessage());
View Full Code Here

    try {
        if (wb instanceof HSSFWorkbook) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream(8192);
                wb.write(baos);
                InputStream is = new ByteArrayInputStream(baos.toByteArray());
          result = new HSSFWorkbook(is);
        } else if (wb instanceof XSSFWorkbook) {
                File tmp = File.createTempFile("poi-ooxml-", ".xlsx");
                tmp.deleteOnExit();
                FileOutputStream out = new FileOutputStream(tmp);
                wb.write(out);
View Full Code Here

    confirm(new StringEval("0.2"), 0.002);
    confirm(BoolEval.TRUE, 0.01);
  }

  public void testInSpreadSheet() {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("Sheet1");
    HSSFRow row = sheet.createRow(0);
    HSSFCell cell = row.createCell((short)0);
    cell.setCellFormula("B1%");
    row.createCell((short)1).setCellValue(50.0);
   
View Full Code Here

      isurl = true;
      if (filename == null) filename = getParameter("url");
      i = getXLSFromURL(filename);
    }

    HSSFWorkbook wb = null;
    if (isurl) {
      wb = constructWorkbook(i);
    } else {
      wb = constructWorkbook(filename);
    }
View Full Code Here

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(panel, BorderLayout.CENTER);
  }

  private HSSFWorkbook constructWorkbook(String filename) throws FileNotFoundException, IOException {
    HSSFWorkbook wb = null;
      FileInputStream in = new FileInputStream(filename);
      wb = new HSSFWorkbook(in);
      in.close();
    return wb;
  }
View Full Code Here

      in.close();
    return wb;
  }

  private HSSFWorkbook constructWorkbook(InputStream in) throws IOException {
    HSSFWorkbook wb = null;

      wb = new HSSFWorkbook(in);
      in.close();
    return wb;
  }
View Full Code Here

    public GenericFormulaTestCase(String beginCell) throws Exception {
        super("genericTest");
        if (workbook == null) {
          FileInputStream fin = new FileInputStream( FILENAME );
          workbook = new HSSFWorkbook( fin );
          fin.close();       
        }
        this.beginCell = new CellReference(beginCell);
    }
View Full Code Here

        try
        {
            fileIn = new FileInputStream("workbook.xls");
            POIFSFileSystem fs = new POIFSFileSystem(fileIn);
            HSSFWorkbook wb = new HSSFWorkbook(fs);
            HSSFSheet sheet = wb.getSheetAt(0);
            HSSFRow row = sheet.getRow(2);
            if (row == null)
                row = sheet.createRow(2);
            HSSFCell cell = row.getCell((short)3);
            if (cell == null)
                cell = row.createCell((short)3);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue("a test");

            // Write the output to a file
            fileOut = new FileOutputStream("workbookout.xls");
            wb.write(fileOut);
        }
        finally
        {
            if (fileOut != null)
                fileOut.close();
View Full Code Here

TOP

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

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.