Package org.apache.poi.hssf.usermodel

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


         {
            throw new DocumentReadException("Can't open spreadsheet.", e);
         }
         for (int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++)
         {
            HSSFSheet sheet = wb.getSheetAt(sheetNum);
            if (sheet != null)
            {
               for (int rowNum = sheet.getFirstRowNum(); rowNum <= sheet.getLastRowNum(); rowNum++)
               {
                  HSSFRow row = sheet.getRow(rowNum);

                  if (row != null)
                  {
                     int lastcell = row.getLastCellNum();
                     for (int k = 0; k < lastcell; k++)
View Full Code Here


    public List<ScorecardError>  parseFile(InputStream inStream, String worksheetName) throws ScorecardParseException {
        try {
            excelDataCollector = new XLSEventDataCollector();
            excelDataCollector.setParser(this);
            HSSFWorkbook workbook = new HSSFWorkbook(inStream);
            HSSFSheet worksheet = workbook.getSheet(worksheetName);
            if (worksheet != null) {
                currentWorksheet = worksheet;
                excelDataCollector.sheetStart(worksheetName);
                excelDataCollector.setMergedRegionsInSheet(getMergedCellRangeList(worksheet));
                processSheet(worksheet);
View Full Code Here

      fs = new POIFSFileSystem(is);
      wb = new HSSFWorkbook(fs);
      if (wb != null) {
        int Scount = wb.getNumberOfSheets();
        for (int s = 0; s < Scount; s++) {
          HSSFSheet sheet = wb.getSheetAt(s);
          if (sheet != null) {
            int Rcount = sheet.getPhysicalNumberOfRows();
            for (int r = 0; r < Rcount; r++) {
              HSSFRow row = sheet.getRow(r);
              if (row != null) {
                int cCount = row.getPhysicalNumberOfCells();
                for (int c = 0; c < cCount; c++) {
                  HSSFCell cell = row.getCell(c);
                  if (cell != null) {
View Full Code Here

        throws Exception
    {
        POIFSFileSystem fs      =
                new POIFSFileSystem(new FileInputStream("workbook.xls"));
        HSSFWorkbook wb = new HSSFWorkbook(fs);
        HSSFSheet sheet = wb.getSheetAt(0);
        HSSFRow row = sheet.getRow(0);
        System.out.println(row.getCell((short)0).getDateCellValue());
        System.out.println(row.getCell((short)0).getCellStyle().getDataFormat());
         row = sheet.getRow(1);
        System.out.println(row.getCell((short)0).getNumericCellValue());
    }
View Full Code Here

        HSSFWorkbook wb = new HSSFWorkbook();

        HSSFFont font = wb.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        HSSFSheet worksheet = wb.createSheet("Customers");
        worksheet.setColumnWidth((short) 0, (short)(20 * 256));
        worksheet.setColumnWidth((short) 1, (short)(30 * 256));
        worksheet.setColumnWidth((short) 4, (short)(20 * 256));

        HSSFRow row = worksheet.createRow((short)0);

        HSSFRichTextString value = new HSSFRichTextString("Customers");
        value.applyFont(font);
        row.createCell((short)0).setCellValue(value);

        row = worksheet.createRow((short)1);
        row.createCell((short)0).setCellValue(new HSSFRichTextString("Customer Account Details"));

        worksheet.createRow((short)2);

        row = worksheet.createRow((short)3);

        HSSFCellStyle style = wb.createCellStyle();
        style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        font = wb.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        value = new HSSFRichTextString("Name");
        value.applyFont(font);
        HSSFCell cell = row.createCell((short)0);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Email");
        value.applyFont(font);
        cell = row.createCell((short)1);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Age");
        value.applyFont(font);
        cell = row.createCell((short)2);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Holdings");
        value.applyFont(font);
        cell = row.createCell((short)3);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Investments");
        value.applyFont(font);
        cell = row.createCell((short)4);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        int rowIndex = 4;

        List<Customer> customers = customerService.getCustomers();
        for (int i = 0; i < customers.size(); i++) {
            Customer customer = (Customer) customers.get(i);

            row = worksheet.createRow((short) rowIndex++);

            row.createCell((short) 0).setCellValue(new HSSFRichTextString(customer.getName()));
            row.createCell((short) 1).setCellValue(new HSSFRichTextString(customer.getEmail()));

            if (customer.getAge() != null) {
View Full Code Here

        locale = context.getLocale();
        currency = Currency.getInstance(locale);

        currentRow = 0;

        HSSFSheet sheet =
            wb.createSheet(StringUtils.capitalize(table.getName()));
        createCellStyles(table, sheet, context);
        exportTableHeader(table, sheet, context);
        exportTableBody(table, sheet, context);

        int count = 0;
        while (count <= table.getColumnList().size()) {
            sheet.autoSizeColumn(count++);
        }

        wb.write(output);
    }
View Full Code Here

    HSSFWorkbook wb = new HSSFWorkbook(input);
    if (wb == null) {
      return resultText.toString();
    }
   
    HSSFSheet sheet;
    HSSFRow row;
    HSSFCell cell;
    int sNum = 0;
    int rNum = 0;
    int cNum = 0;
   
    sNum = wb.getNumberOfSheets();
   
    for (int i=0; i<sNum; i++) {
      if ((sheet = wb.getSheetAt(i)) == null) {
        continue;
      }
      rNum = sheet.getLastRowNum();
      for (int j=0; j<=rNum; j++) {
        if ((row = sheet.getRow(j)) == null){
          continue;
        }
        cNum = row.getLastCellNum();
       
        for (int k=0; k<cNum; k++) {
View Full Code Here

    }
  }

  private static HSSFWorkbook createWorkbook(UIData table, FacesContext context) {
    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet sheet = workbook.createSheet(table.getId());
    List<UIColumn> columns = getColumns(table);
    int currentRowIndex = table.getRowIndex();
    addColumnHeaders(sheet, columns, context);
    addColumnValues(sheet, columns, table, context);
    table.setRowIndex(currentRowIndex);
View Full Code Here

                return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                        "ProductProductImportCannotCreateWorkbookFromFile", locale));
            }

            // get first sheet
            HSSFSheet sheet = wb.getSheetAt(0);
            int sheetLastRowNumber = sheet.getLastRowNum();
            for (int j = 1; j <= sheetLastRowNumber; j++) {
                HSSFRow row = sheet.getRow(j);
                if (row != null) {
                    // read productId from first column "sheet column index
                    // starts from 0"
                    HSSFCell cell2 = row.getCell(2);
                    cell2.setCellType(HSSFCell.CELL_TYPE_STRING);
View Full Code Here

    final MasterReport report = DebugReportRunner.parseGoldenSampleReport("Prd-3889.prpt");
    final ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ExcelReportUtil.createXLS(report, bout);

    final HSSFWorkbook wb = new HSSFWorkbook(new ByteArrayInputStream(bout.toByteArray()));
    final HSSFSheet sheetAt = wb.getSheetAt(0);
    final HSSFRow row = sheetAt.getRow(0);
    final HSSFCell cell0 = row.getCell(0);

    // assert that we are in the correct export type ..
    final HSSFCellStyle cellStyle = cell0.getCellStyle();
    final HSSFColor fillBackgroundColorColor = cellStyle.getFillBackgroundColorColor();
    final HSSFColor fillForegroundColorColor = cellStyle.getFillForegroundColorColor();
    assertEquals("0:0:0", fillBackgroundColorColor.getHexString());
    assertEquals("FFFF:FFFF:9999", fillForegroundColorColor.getHexString());

    // assert that there are no extra columns ..
    final HSSFRow row8 = sheetAt.getRow(7);
    assertNull(row8);

  }
View Full Code Here

TOP

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

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.