changed CRLF to LF in src/examples/.../xssf/...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@781837 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3280064978
commit
bf6b4439b3
@ -14,20 +14,21 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.xssf.usermodel.examples;
|
||||
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STHorizontalAlignment;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
|
||||
/**
|
||||
* Shows how various alignment options work.
|
||||
*/
|
||||
public class AligningCells {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
public static void main(String[] args) throws IOException {
|
||||
Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
|
||||
|
||||
Sheet sheet = wb.createSheet();
|
||||
@ -50,7 +51,6 @@ public class AligningCells {
|
||||
FileOutputStream fileOut = new FileOutputStream("xssf-align.xlsx");
|
||||
wb.write(fileOut);
|
||||
fileOut.close();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,5 +69,4 @@ public class AligningCells {
|
||||
cellStyle.setVerticalAlignment(valign);
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,18 +14,19 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.xssf.usermodel.examples;
|
||||
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellReference;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.ss.util.CellReference;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
|
||||
/**
|
||||
* Demonstrates a workaround you can use to generate large workbooks and avoid OutOfMemory exception.
|
||||
@ -153,8 +154,10 @@ public class BigGridDemo {
|
||||
|
||||
ZipOutputStream zos = new ZipOutputStream(out);
|
||||
|
||||
for (Enumeration en = zip.entries(); en.hasMoreElements(); ) {
|
||||
ZipEntry ze = (ZipEntry)en.nextElement();
|
||||
@SuppressWarnings("unchecked")
|
||||
Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
|
||||
while (en.hasMoreElements()) {
|
||||
ZipEntry ze = en.nextElement();
|
||||
if(!ze.getName().equals(entry)){
|
||||
zos.putNextEntry(new ZipEntry(ze.getName()));
|
||||
InputStream is = zip.getInputStream(ze);
|
||||
@ -183,22 +186,22 @@ public class BigGridDemo {
|
||||
* (YK: in future it may evolve in a full-featured API for streaming data in Excel)
|
||||
*/
|
||||
public static class SpreadsheetWriter {
|
||||
private Writer out;
|
||||
private int rownum;
|
||||
private final Writer _out;
|
||||
private int _rownum;
|
||||
|
||||
public SpreadsheetWriter(Writer out){
|
||||
this.out = out;
|
||||
_out = out;
|
||||
}
|
||||
|
||||
public void beginSheet() throws IOException {
|
||||
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
_out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
"<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">" );
|
||||
out.write("<sheetData>\n");
|
||||
_out.write("<sheetData>\n");
|
||||
}
|
||||
|
||||
public void endSheet() throws IOException {
|
||||
out.write("</sheetData>");
|
||||
out.write("</worksheet>");
|
||||
_out.write("</sheetData>");
|
||||
_out.write("</worksheet>");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,24 +210,24 @@ public class BigGridDemo {
|
||||
* @param rownum 0-based row number
|
||||
*/
|
||||
public void insertRow(int rownum) throws IOException {
|
||||
out.write("<row r=\""+(rownum+1)+"\">\n");
|
||||
this.rownum = rownum;
|
||||
_out.write("<row r=\""+(rownum+1)+"\">\n");
|
||||
this._rownum = rownum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert row end marker
|
||||
*/
|
||||
public void endRow() throws IOException {
|
||||
out.write("</row>\n");
|
||||
_out.write("</row>\n");
|
||||
}
|
||||
|
||||
public void createCell(int columnIndex, String value, int styleIndex) throws IOException {
|
||||
String ref = new CellReference(rownum, columnIndex).formatAsString();
|
||||
out.write("<c r=\""+ref+"\" t=\"inlineStr\"");
|
||||
if(styleIndex != -1) out.write(" s=\""+styleIndex+"\"");
|
||||
out.write(">");
|
||||
out.write("<is><t>"+value+"</t></is>");
|
||||
out.write("</c>");
|
||||
String ref = new CellReference(_rownum, columnIndex).formatAsString();
|
||||
_out.write("<c r=\""+ref+"\" t=\"inlineStr\"");
|
||||
if(styleIndex != -1) _out.write(" s=\""+styleIndex+"\"");
|
||||
_out.write(">");
|
||||
_out.write("<is><t>"+value+"</t></is>");
|
||||
_out.write("</c>");
|
||||
}
|
||||
|
||||
public void createCell(int columnIndex, String value) throws IOException {
|
||||
@ -232,12 +235,12 @@ public class BigGridDemo {
|
||||
}
|
||||
|
||||
public void createCell(int columnIndex, double value, int styleIndex) throws IOException {
|
||||
String ref = new CellReference(rownum, columnIndex).formatAsString();
|
||||
out.write("<c r=\""+ref+"\" t=\"n\"");
|
||||
if(styleIndex != -1) out.write(" s=\""+styleIndex+"\"");
|
||||
out.write(">");
|
||||
out.write("<v>"+value+"</v>");
|
||||
out.write("</c>");
|
||||
String ref = new CellReference(_rownum, columnIndex).formatAsString();
|
||||
_out.write("<c r=\""+ref+"\" t=\"n\"");
|
||||
if(styleIndex != -1) _out.write(" s=\""+styleIndex+"\"");
|
||||
_out.write(">");
|
||||
_out.write("<v>"+value+"</v>");
|
||||
_out.write("</c>");
|
||||
}
|
||||
|
||||
public void createCell(int columnIndex, double value) throws IOException {
|
||||
@ -248,5 +251,4 @@ public class BigGridDemo {
|
||||
createCell(columnIndex, DateUtil.getExcelDate(value, false), styleIndex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.xssf.usermodel.examples;
|
||||
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
|
@ -21,7 +21,6 @@ import java.io.FileOutputStream;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.xssf.usermodel.examples;
|
||||
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
@ -39,6 +40,5 @@ public class IterateCells {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.xssf.usermodel.examples;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
@ -23,7 +24,6 @@ import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
||||
import org.apache.poi.hssf.util.Region;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
@ -45,6 +45,5 @@ public class MergingCells {
|
||||
FileOutputStream fileOut = new FileOutputStream("merging_cells.xlsx");
|
||||
wb.write(fileOut);
|
||||
fileOut.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,14 +21,13 @@ import java.io.FileOutputStream;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
|
||||
public class SelectedSheet {
|
||||
|
||||
public static void main(String[]args) throws Exception {
|
||||
Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
|
||||
Sheet sheet = wb.createSheet("row sheet");
|
||||
|
||||
Sheet sheet = wb.createSheet("row sheet");
|
||||
Sheet sheet2 = wb.createSheet("another sheet");
|
||||
Sheet sheet3 = wb.createSheet(" sheet 3 ");
|
||||
sheet3.setSelected(true);
|
||||
|
@ -14,6 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.xssf.usermodel.examples;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
@ -45,6 +46,5 @@ public class SplitAndFreezePanes {
|
||||
FileOutputStream fileOut = new FileOutputStream("splitFreezePane.xlsx");
|
||||
wb.write(fileOut);
|
||||
fileOut.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.xssf.usermodel.examples;
|
||||
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
@ -53,6 +54,5 @@ public class WorkingWithBorders {
|
||||
FileOutputStream fileOut = new FileOutputStream("xssf-borders.xlsx");
|
||||
wb.write(fileOut);
|
||||
fileOut.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.xssf.usermodel.examples;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
|
@ -14,12 +14,12 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.xssf.usermodel.examples;
|
||||
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -65,6 +65,5 @@ public class WorkingWithPictures {
|
||||
FileOutputStream fileOut = new FileOutputStream(file);
|
||||
wb.write(fileOut);
|
||||
fileOut.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.xssf.usermodel.examples;
|
||||
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
@ -57,5 +58,4 @@ public class WorkingWithRichText {
|
||||
wb.write(fileOut);
|
||||
fileOut.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user