Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.Row


     */
    public void test50416LastRowNumber() {
       // Create the workbook with 1 sheet which contains 3 rows
       HSSFWorkbook workbook = new HSSFWorkbook();
       Sheet sheet = workbook.createSheet("Bug50416");
       Row row1 = sheet.createRow(0);
       Cell cellA_1 = row1.createCell(0,Cell.CELL_TYPE_STRING);
       cellA_1.setCellValue("Cell A,1");
       Row row2 = sheet.createRow(1);
       Cell cellA_2 = row2.createCell(0,Cell.CELL_TYPE_STRING);
       cellA_2.setCellValue("Cell A,2");
       Row row3 = sheet.createRow(2);
       Cell cellA_3 = row3.createCell(0,Cell.CELL_TYPE_STRING);
       cellA_3.setCellValue("Cell A,3");
      
       // Test the last Row number it currently correct
       assertEquals(2, sheet.getLastRowNum());
      
View Full Code Here


    result.startTag("h2");
    result.addText(xssfSheet.getSheetName());
    result.endTag();
   
    for (int i = xssfSheet.getFirstRowNum(); i <= xssfSheet.getLastRowNum(); i++) {
      Row row = xssfSheet.getRow(i);
      rowStrategy.process(row, result);
    }
   
    result.endTag();
  }
View Full Code Here

    int rowTo = table.getEndCellReference().getRow();
    XSSFSheet sheet = table.getXSSFSheet();
       
    result.startTag("table");
    for (int rowNum = rowFrom; rowNum <= rowTo; rowNum++) {
      Row r = sheet.getRow(rowNum);
      result.startTag("tr");
      for (int i = columnFrom; i <= columnTo; i++) {
        if (header) {
          headerCell.process(r.getCell(i), result);
        } else {
          bodyCell.process(r.getCell(i), result);
        }
      }
     
      header = false;
      result.endTag();
View Full Code Here

      if (firstRowIsHeader)
      {
        if (rowIterator.hasNext())
        {
          final Row headerRow = (Row) rowIterator.next();
          final short cellCount = headerRow.getLastCellNum();
          for (short colIdx = 0; colIdx < cellCount; colIdx++)
          {
            final Cell cell = headerRow.getCell(colIdx);
            if (cell != null)
            {
              while (colIdx > tableModel.getColumnCount())
              {
                tableModel.addColumn(Messages.getString("TableDataSourceEditor.Column",
                    String.valueOf(tableModel.getColumnCount())), Object.class);
              }

              final RichTextString string = cell.getRichStringCellValue();
              if (string != null)
              {
                tableModel.addColumn(string.getString(), Object.class);
              }
              else
              {
                tableModel.addColumn(Messages.getString("TableDataSourceEditor.Column", String.valueOf(colIdx)), Object.class);
              }
            }
          }
        }
      }

      Object[] rowData = null;
      while (rowIterator.hasNext())
      {
        final Row row = (Row) rowIterator.next();
        final short cellCount = row.getLastCellNum();
        if (cellCount == -1)
        {
          continue;
        }
        if (rowData == null || rowData.length != cellCount)
        {
          rowData = new Object[cellCount];
        }

        for (short colIdx = 0; colIdx < cellCount; colIdx++)
        {
          final Cell cell = row.getCell(colIdx);

          final Object value;
          if (cell != null)
          {
            if (cell.getCellType() == Cell.CELL_TYPE_STRING)
View Full Code Here

   {
      int intRowCount = 0;

      HSSFWorkbook wbk = new HSSFWorkbook();
      HSSFSheet sht = wbk.createSheet("First sheet");
      Row rowHeader = sht.createRow(intRowCount);
      rowHeader.setHeightInPoints(30);

      // ---

      for (int i = 0; i < lstLst.size(); i++)
      {
         Row rowCur = sht.createRow(intRowCount);

         List<String> lstCur = lstLst.get(i);

         for (int j = 0; j < lstCur.size(); j++)
         {
            Cell celCur = rowCur.createCell(j);
            celCur.setCellValue(lstCur.get(j));
         }

         intRowCount++;
      }
View Full Code Here

            xhtml.startElement("tbody");

            // Rows and cells
            for (Object rawR : sheet) {
                xhtml.startElement("tr");
                Row row = (Row) rawR;
                for (Iterator<Cell> ri = row.cellIterator(); ri.hasNext();) {
                    xhtml.startElement("td");
                    Cell cell = ri.next();

                    if (cell.getCellType() == Cell.CELL_TYPE_FORMULA
                            || cell.getCellType() == Cell.CELL_TYPE_STRING) {
View Full Code Here

     */
    public static double getCellWidth(Cell cell, int defaultCharWidth, DataFormatter formatter, boolean useMergedCells) {

        Sheet sheet = cell.getSheet();
        Workbook wb = sheet.getWorkbook();
        Row row = cell.getRow();
        int column = cell.getColumnIndex();

        int colspan = 1;
        for (int i = 0 ; i < sheet.getNumMergedRegions(); i++) {
            CellRangeAddress region = sheet.getMergedRegion(i);
            if (containsCell(region, row.getRowNum(), column)) {
                if (!useMergedCells) {
                    // If we're not using merged cells, skip this one and move on to the next.
                    return -1;
                }
                cell = row.getCell(region.getFirstColumn());
                colspan = 1 + region.getLastColumn() - region.getFirstColumn();
            }
        }

        CellStyle style = cell.getCellStyle();
View Full Code Here

        layout = new TextLayout(str.getIterator(), fontRenderContext);
        int defaultCharWidth = (int)layout.getAdvance();

        double width = -1;
        for (int rowIdx = firstRow; rowIdx <= lastRow; ++rowIdx) {
            Row row = sheet.getRow(rowIdx);
            if( row != null ) {

                Cell cell = row.getCell(column);

                if (cell == null) {
                    continue;
                }
View Full Code Here

  public void testMissingWorkbookMissing() throws IOException {
    FormulaEvaluator evaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator();
   
    Sheet lSheet = mainWorkbook.getSheetAt(0);
    Row lARow = lSheet.getRow(0);
    Cell lA1Cell = lARow.getCell(0);
   
    assertEquals(Cell.CELL_TYPE_FORMULA, lA1Cell.getCellType());
    try {
      evaluator.evaluateFormulaCell(lA1Cell);
      fail("Missing external workbook reference exception expected!");
View Full Code Here

    HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(workbook);
        Collection<String> funcs = FunctionEval.getSupportedFunctionNames();

    int rowIndex = startRowIndex;
    while (true) {
      Row r = sheet.getRow(rowIndex);
     
      // only evaluate non empty row
      if( r != null )
      {
        String targetFunctionName = getTargetFunctionName(r);
        String targetTestName = getTargetTestName(r);
        if(targetFunctionName == null) {
          throw new AssertionFailedError("Test spreadsheet cell empty on row ("
              + (rowIndex+1) + "). Expected function name or '"
              + SS.FUNCTION_NAMES_END_SENTINEL + "'");
        }
        if(targetFunctionName.equals(SS.FUNCTION_NAMES_END_SENTINEL)) {
          // found end of functions list
          break;
        }
        if(testFocusFunctionName == null || targetFunctionName.equalsIgnoreCase(testFocusFunctionName)) {

          // expected results are on the row below
          Cell expectedValueCell = r.getCell(SS.COLUMN_INDEX_EXPECTED_VALUE);
          if(expectedValueCell == null) {
            int missingRowNum = rowIndex + 1;
            throw new AssertionFailedError("Missing expected values cell for function '"
                + targetFunctionName + ", test" + targetTestName + " (row " +
                missingRowNum + ")");
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.Row

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.