You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2017/08/17 23:05:31 UTC

svn commit: r1805345 - in /poi/site: publish/poi-jvm-languages.html src/documentation/content/xdocs/poi-jvm-languages.xml

Author: onealj
Date: Thu Aug 17 23:05:31 2017
New Revision: 1805345

URL: http://svn.apache.org/viewvc?rev=1805345&view=rev
Log:
add Clojure example, provided by Blake Watson from the POI mailing list

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=1805345&r1=1805344&r2=1805345&view=diff
==============================================================================
--- poi/site/publish/poi-jvm-languages.html (original)
+++ poi/site/publish/poi-jvm-languages.html Thu Aug 17 23:05:31 2017
@@ -545,6 +545,44 @@ WorkbookFactory.create(f,null,true).with
       </pre>
     
     
+
+    
+<a name="Clojure+example"></a>
+<div class="h3">
+<h3>Clojure example<a title="Permanent link" class="headerlink" href="#Clojure+example">#</a>
+</h3>
+</div>
+    
+<a name="SpreadSheetDemo.clj"></a>
+<div class="h4">
+<h4>SpreadSheetDemo.clj<a title="Permanent link" class="headerlink" href="#SpreadSheetDemo.clj">#</a>
+</h4>
+</div>
+      
+      
+<pre class="code"> 
+(ns poi.core
+    (:gen-class)
+    (:use [clojure.java.io :only [input-stream]])
+    (:import [org.apache.poi.ss.usermodel WorkbookFactory DataFormatter]))
+
+
+(defn sheets [wb] (map #(.getSheetAt wb %1) (range 0 (.getNumberOfSheets wb))))
+
+(defn print-all [wb]
+  (let [df (DataFormatter.)]
+    (doseq [sheet (sheets wb)]
+      (doseq [row (seq sheet)]
+        (doseq [cell (seq row)]
+          (println (.formatAsString (.getAddress cell)) ": " (.formatCellValue df cell)))))))
+
+(defn -main [&amp; args]
+  (when-let [name (first args)]
+    (let [wb (WorkbookFactory/create (input-stream name))]
+      (print-all wb))))
+      </pre>
+    
+    
   
   
 

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=1805345&r1=1805344&r2=1805345&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml (original)
+++ poi/site/src/documentation/content/xdocs/poi-jvm-languages.xml Thu Aug 17 23:05:31 2017
@@ -38,6 +38,7 @@
        <li><link href="#Jython+example">Jython</link></li>
        <li><link href="#Scala+example">Scala</link></li>
        <li><link href="#Groovy+example">Groovy</link></li>
+       <li><link href="#Clojure+example">Clojure</link></li>
       </ul>
     </section>
 
@@ -47,6 +48,7 @@
         <li><link href="http://www.jython.org/">Jython</link> 2.5+ (older versions probably work, but are untested)</li>
         <li><link href="http://www.scala-lang.org/">Scala</link> 2.x</li>
         <li><link href="http://groovy-lang.org/">Groovy</link> 2.4 (anything from 1.6 onwards ought to work, but only the latest 2.4 releases have been tested by us)</li>
+        <li><link href="http://clojure.org/">Clojure</link></li>
       </ul>
       <p>Please <link href="mailinglists.html">let us know</link> if you use POI in an environment not listed here</p>
     </section>
@@ -231,6 +233,33 @@ WorkbookFactory.create(f,null,true).with
       </source>
     </section>
     </section>
+
+    <section><title>Clojure example</title>
+    <section><title>SpreadSheetDemo.clj</title>
+      <!-- code example provided by Blake Watson -->
+      <source> <!-- lang="clojure" -->
+(ns poi.core
+    (:gen-class)
+    (:use [clojure.java.io :only [input-stream]])
+    (:import [org.apache.poi.ss.usermodel WorkbookFactory DataFormatter]))
+
+
+(defn sheets [wb] (map #(.getSheetAt wb %1) (range 0 (.getNumberOfSheets wb))))
+
+(defn print-all [wb]
+  (let [df (DataFormatter.)]
+    (doseq [sheet (sheets wb)]
+      (doseq [row (seq sheet)]
+        (doseq [cell (seq row)]
+          (println (.formatAsString (.getAddress cell)) ": " (.formatCellValue df cell)))))))
+
+(defn -main [&amp; args]
+  (when-let [name (first args)]
+    (let [wb (WorkbookFactory/create (input-stream name))]
+      (print-all wb))))
+      </source>
+    </section>
+    </section>
   </body>
   <footer>
     <legal>



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