From 15826b72f2b1cf962312bb7b1023f755ace5d190 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 27 Oct 2008 17:59:39 +0000 Subject: [PATCH] Patch from bug #46092 - fix hssf dev utility git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@708252 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/hssf/dev/HSSF.java | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/poi/hssf/dev/HSSF.java b/src/java/org/apache/poi/hssf/dev/HSSF.java index 43afead985..2bc41889e2 100644 --- a/src/java/org/apache/poi/hssf/dev/HSSF.java +++ b/src/java/org/apache/poi/hssf/dev/HSSF.java @@ -221,7 +221,7 @@ public class HSSF if (args.length < 2) { -/* try + try { HSSF hssf = new HSSF(args[ 0 ]); @@ -230,26 +230,30 @@ public class HSSF for (int k = 0; k < wb.getNumberOfSheets(); k++) { - System.out.println("Sheet " + k); HSSFSheet sheet = wb.getSheetAt(k); int rows = sheet.getPhysicalNumberOfRows(); - + System.out.println("Sheet " + k + " \"" + + wb.getSheetName(k) + "\" has " + + rows + " row(s)."); for (int r = 0; r < rows; r++) { - HSSFRow row = sheet.getPhysicalRowAt(r); - int cells = row.getPhysicalNumberOfCells(); - - System.out.println("ROW " + row.getRowNum()); + HSSFRow row = sheet.getRow(r); + int cells = (row != null) ? row.getPhysicalNumberOfCells() : 0; + if (row != null) { + System.out.println("\nROW " + row.getRowNum() + + " has " + cells + " cell(s)."); + } for (int c = 0; c < cells; c++) { - HSSFCell cell = row.getPhysicalCellAt(c); + HSSFCell cell = row.getCell(c); String value = null; switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_FORMULA : - value = "FORMULA "; + value = "FORMULA value=" + + cell.getCellFormula(); break; case HSSFCell.CELL_TYPE_NUMERIC : @@ -274,7 +278,7 @@ public class HSSF catch (Exception e) { e.printStackTrace(); - }*/ + } } else if (args.length == 2) {