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 2016/07/15 20:48:30 UTC
svn commit: r1752878 - /poi/site/publish/poi-jvm-languages.html
Author: onealj
Date: Fri Jul 15 20:48:30 2016
New Revision: 1752878
URL: http://svn.apache.org/viewvc?rev=1752878&view=rev
Log:
republish poi-jvm-languages
Modified:
poi/site/publish/poi-jvm-languages.html
Modified: poi/site/publish/poi-jvm-languages.html
URL: http://svn.apache.org/viewvc/poi/site/publish/poi-jvm-languages.html?rev=1752878&r1=1752877&r2=1752878&view=diff
==============================================================================
--- poi/site/publish/poi-jvm-languages.html (original)
+++ poi/site/publish/poi-jvm-languages.html Fri Jul 15 20:48:30 2016
@@ -307,6 +307,64 @@ if (VERSION > 3) {
<p>Please let us know if you use POI in an environment not listed here</p>
+
+<a name="Java+code"></a>
+<div class="h3">
+<h3>Java code</h3>
+</div>
+
+<pre class="code">
+ // include poi-{version}-{yyyymmdd}.jar, poi-ooxml-{version}-{yyyymmdd}.jar, and poi-ooxml-schemas-{version}-{yyyymmdd}.jar on Java classpath
+ </pre>
+
+
+<a name="POILanguageExample.java"></a>
+<div class="h4">
+<h4>POILanguageExample.java</h4>
+</div>
+
+<pre class="code"> <!-- lang="java" -->
+ // Import the POI classes
+ import java.io.File;
+ import java.io.FileOutputStream;
+ import java.io.OutputStream;
+ import org.apache.poi.ss.usermodel.Cell;
+ import org.apache.poi.ss.usermodel.Row;
+ import org.apache.poi.ss.usermodel.Sheet;
+ import org.apache.poi.ss.usermodel.Workbook;
+ import org.apache.poi.ss.usermodel.WorkbookFactory;
+ import org.apache.poi.ss.usermodel.DataFormatter;
+
+ // Read the contents of the workbook
+ File f = new File("SampleSS.xlsx");
+ Workbook wb = WorkbookFactory.create(f);
+ DataFormatter formatter = new DataFormatter();
+ int i = 1;
+ int numberOfSheets = wb.getNumberOfSheets();
+ for ( Sheet sheet : wb ) {
+ System.out.println("Sheet " + i + " of " + numberOfSheets + ": " + sheet.getSheetName());
+ for ( Row row : sheet ) {
+ System.out.println("\tRow " + row.getRowNum());
+ for ( Cell cell : row ) {
+ System.out.println("\t\t"+ cell.getAddress().formatAsString() + ": " + formatter.formatCellValue(cell));
+ }
+ }
+ }
+
+ // Modify the workbook
+ Sheet sh = wb.createSheet("new sheet");
+ Row row = sh.createRow(7);
+ Cell cell = row.createCell(42);
+ cell.setActiveCell(true);
+ cell.setCellValue("The answer to life, the universe, and everything");
+
+ // Save and close the workbook
+ OutputStream fos = new FileOutputStream("SampleSS-updated.xlsx");
+ wb.write(fos);
+ fos.close();
+ </pre>
+ <!-- POILanguageExample.java -->
+ <!-- Java code -->
<a name="Jython+example"></a>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org