Author: onealj
Date: Mon Aug 22 17:47:56 2016
New Revision: 1757234

URL: http://svn.apache.org/viewvc?rev=1757234&view=rev
Log:
mention DataFormatter, as this is the most likely use case for getting the cell 
value

Modified:
    poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml

Modified: poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml
URL: 
http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml?rev=1757234&r1=1757233&r2=1757234&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml 
(original)
+++ poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml Mon 
Aug 22 17:47:56 2016
@@ -398,6 +398,7 @@
                                <source>
     // import org.apache.poi.ss.usermodel.*;
 
+    DataFormatter formatter = new DataFormatter();
     Sheet sheet1 = wb.getSheetAt(0);
     for (Row row : sheet1) {
         for (Cell cell : row) {
@@ -405,6 +406,11 @@
             System.out.print(cellRef.formatAsString());
             System.out.print(" - ");
 
+            // get the text that appears in the cell by getting the cell value 
and applying any data formats (Date, 0.00, 1.23e9, $1.23, etc)
+            String text = formatter.formatCellValue(cell);
+            System.out.println(text);
+
+            // Alternatively, get the value and format it yourself
             switch (cell.getCellTypeEnum()) {
                 case CellType.STRING:
                     
System.out.println(cell.getRichStringCellValue().getString());
@@ -422,6 +428,9 @@
                 case CellType.FORMULA:
                     System.out.println(cell.getCellFormula());
                     break;
+                case CellType.BLANK:
+                    System.out.println();
+                    break;
                 default:
                     System.out.println();
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to