Author: onealj
Date: Fri Jul 15 05:10:34 2016
New Revision: 1752770

URL: http://svn.apache.org/viewvc?rev=1752770&view=rev
Log:
update Jython example to import the correct classes; update Scala example to 
exactly mirror Jython example

Modified:
    poi/site/publish/poi-jvm-languages.html
    poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml

Modified: poi/site/publish/poi-jvm-languages.html
URL: 
http://svn.apache.org/viewvc/poi/site/publish/poi-jvm-languages.html?rev=1752770&r1=1752769&r2=1752770&view=diff
==============================================================================
--- poi/site/publish/poi-jvm-languages.html (original)
+++ poi/site/publish/poi-jvm-languages.html Fri Jul 15 05:10:34 2016
@@ -297,12 +297,14 @@ if (VERSION > 3) {
     import sys
     for jar in ('poi', 'poi-ooxml', 'poi-ooxml-schemas'):
         sys.path.append('/path/to/%s-3.14-20160307.jar')
+        
+    from java.io import File, FileOutputStream
 
     # Import the POI classes
     from org.apache.poi.ss.usermodel import <a 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/WorkbookFactory.html";>WorkbookFactory</a>,
 <a 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DataFormatter.html";>DataFormatter</a>
 
     # Read the contents of the workbook
-    wb = XSSFWorkbook('<a 
href="https://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/SampleSS.xlsx";>SampleSS.xlsx</a>')
+    wb = WorkbookFactory.create(File('<a 
href="https://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/SampleSS.xlsx";>SampleSS.xlsx</a>'))
     formatter = DataFormatter()
     for i, sheet in enumerate(wb, start=1):
         print('Sheet %d of %d: %s'.format(i, wb.numberOfSheets, 
sheet.sheetName))
@@ -319,8 +321,7 @@ if (VERSION > 3) {
     cell.cellValue = 'The answer to life, the universe, and everything'
 
     # Save and close the workbook
-    from java.io import FileOutputStream
-    fos = FileOutputStream('SampleSS-saved.xlsx')
+    fos = FileOutputStream('SampleSS-updated.xlsx')
     wb.write(fos)
     wb.close()
       </pre>
@@ -359,8 +360,8 @@ if (VERSION > 3) {
       
 <pre class="code"> <!-- lang="scala" -->
     // Import the required classes
-    import org.apache.poi.xssf.usermodel.XSSFWorkbook
-    import java.io.FileOutputStream
+    import org.apache.poi.ss.usermodel.{<a 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/WorkbookFactory.html";>WorkbookFactory</a>,
 <a 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DataFormatter.html";>DataFormatter</a>}
+    import java.io.{File, FileOutputStream}
 
     object XSSFMain extends App {
 
@@ -368,7 +369,8 @@ if (VERSION > 3) {
         import scala.collection.JavaConversions._
 
         // Read the contents of the workbook
-        val workbook = new XSSFWorkbook("SampleSS.xlsx")
+        val workbook = WorkbookFactory.create(new File("<a 
href="https://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/SampleSS.xlsx";>SampleSS.xlsx</a>"))
+        val formatter = new DataFormatter()
         for {
             // Iterate and print the sheets
             (sheet, i) &lt;- workbook.zipWithIndex
@@ -381,7 +383,7 @@ if (VERSION > 3) {
             // Iterate and print the cells
             cell &lt;- row
         } {
-            println(s"\t\t${cell.getColumnIndex}: ${cell.getStringCellValue}")
+            println(s"\t\t${cell.getCellAddress}: 
${formatter.formatCellValue(cell)}")
         }
 
         // Add a sheet to the workbook
@@ -392,7 +394,7 @@ if (VERSION > 3) {
         cell.setCellValue("The answer to life, the universe, and everything")
 
         // Save the updated workbook as a new file
-        val fos = new FileOutputStream("UpdatedSampleSS.xlsx")
+        val fos = new FileOutputStream("SampleSS-updated.xlsx")
         workbook.write(fos)
         workbook.close()
     }

Modified: poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml
URL: 
http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml?rev=1752770&r1=1752769&r2=1752770&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml (original)
+++ poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml Fri Jul 15 
05:10:34 2016
@@ -51,12 +51,14 @@
     import sys
     for jar in ('poi', 'poi-ooxml', 'poi-ooxml-schemas'):
         sys.path.append('/path/to/%s-3.14-20160307.jar')
+        
+    from java.io import File, FileOutputStream
 
     # Import the POI classes
     from org.apache.poi.ss.usermodel import <link 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/WorkbookFactory.html";>WorkbookFactory</link>,
 <link 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DataFormatter.html";>DataFormatter</link>
 
     # Read the contents of the workbook
-    wb = XSSFWorkbook('<link 
href="https://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/SampleSS.xlsx";>SampleSS.xlsx</link>')
+    wb = WorkbookFactory.create(File('<link 
href="https://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/SampleSS.xlsx";>SampleSS.xlsx</link>'))
     formatter = DataFormatter()
     for i, sheet in enumerate(wb, start=1):
         print('Sheet %d of %d: %s'.format(i, wb.numberOfSheets, 
sheet.sheetName))
@@ -73,8 +75,7 @@
     cell.cellValue = 'The answer to life, the universe, and everything'
 
     # Save and close the workbook
-    from java.io import FileOutputStream
-    fos = FileOutputStream('SampleSS-saved.xlsx')
+    fos = FileOutputStream('SampleSS-updated.xlsx')
     wb.write(fos)
     wb.close()
       </source>
@@ -98,8 +99,8 @@
     <section><title>XSSFMain.scala</title>
       <source> <!-- lang="scala" -->
     // Import the required classes
-    import org.apache.poi.xssf.usermodel.XSSFWorkbook
-    import java.io.FileOutputStream
+    import org.apache.poi.ss.usermodel.{<link 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/WorkbookFactory.html";>WorkbookFactory</link>,
 <link 
href="https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DataFormatter.html";>DataFormatter</link>}
+    import java.io.{File, FileOutputStream}
 
     object XSSFMain extends App {
 
@@ -107,7 +108,8 @@
         import scala.collection.JavaConversions._
 
         // Read the contents of the workbook
-        val workbook = new XSSFWorkbook("SampleSS.xlsx")
+        val workbook = WorkbookFactory.create(new File("<link 
href="https://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/SampleSS.xlsx";>SampleSS.xlsx</link>"))
+        val formatter = new DataFormatter()
         for {
             // Iterate and print the sheets
             (sheet, i) &lt;- workbook.zipWithIndex
@@ -120,7 +122,7 @@
             // Iterate and print the cells
             cell &lt;- row
         } {
-            println(s"\t\t${cell.getColumnIndex}: ${cell.getStringCellValue}")
+            println(s"\t\t${cell.getCellAddress}: 
${formatter.formatCellValue(cell)}")
         }
 
         // Add a sheet to the workbook
@@ -131,7 +133,7 @@
         cell.setCellValue("The answer to life, the universe, and everything")
 
         // Save the updated workbook as a new file
-        val fos = new FileOutputStream("UpdatedSampleSS.xlsx")
+        val fos = new FileOutputStream("SampleSS-updated.xlsx")
         workbook.write(fos)
         workbook.close()
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org
For additional commands, e-mail: commits-h...@poi.apache.org

Reply via email to