]> source.dussan.org Git - poi.git/commitdiff
Patch from bug #46092 - fix hssf dev utility
authorNick Burch <nick@apache.org>
Mon, 27 Oct 2008 17:59:39 +0000 (17:59 +0000)
committerNick Burch <nick@apache.org>
Mon, 27 Oct 2008 17:59:39 +0000 (17:59 +0000)
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

index 43afead985fb540c34bf4edb6fb8a1c8f8b62108..2bc41889e2ac9921f0ac0629c1ce40a07b507c72 100644 (file)
@@ -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)
         {