aboutsummaryrefslogtreecommitdiffstats
path: root/src/examples
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/Alignment.java29
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java30
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/Borders.java13
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/CellComments.java9
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java21
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateCells.java19
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateDateCells.java16
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/FrillsAndFills.java15
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java20
-rwxr-xr-xsrc/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java14
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/MergedCells.java18
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java56
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/NewSheet.java12
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java22
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java21
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/Outlines.java178
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java17
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/RepeatingRowsAndColumns.java24
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/WorkingWithFonts.java14
19 files changed, 213 insertions, 335 deletions
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Alignment.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Alignment.java
index bad05466b4..b54640ee73 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Alignment.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Alignment.java
@@ -29,27 +29,23 @@ import java.io.IOException;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class Alignment
-{
- public static void main(String[] args)
- throws IOException
- {
+public class Alignment {
+ public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
- HSSFRow row = sheet.createRow((short) 2);
- createCell(wb, row, (short) 0, HSSFCellStyle.ALIGN_CENTER);
- createCell(wb, row, (short) 1, HSSFCellStyle.ALIGN_CENTER_SELECTION);
- createCell(wb, row, (short) 2, HSSFCellStyle.ALIGN_FILL);
- createCell(wb, row, (short) 3, HSSFCellStyle.ALIGN_GENERAL);
- createCell(wb, row, (short) 4, HSSFCellStyle.ALIGN_JUSTIFY);
- createCell(wb, row, (short) 5, HSSFCellStyle.ALIGN_LEFT);
- createCell(wb, row, (short) 6, HSSFCellStyle.ALIGN_RIGHT);
+ HSSFRow row = sheet.createRow(2);
+ createCell(wb, row, 0, HSSFCellStyle.ALIGN_CENTER);
+ createCell(wb, row, 1, HSSFCellStyle.ALIGN_CENTER_SELECTION);
+ createCell(wb, row, 2, HSSFCellStyle.ALIGN_FILL);
+ createCell(wb, row, 3, HSSFCellStyle.ALIGN_GENERAL);
+ createCell(wb, row, 4, HSSFCellStyle.ALIGN_JUSTIFY);
+ createCell(wb, row, 5, HSSFCellStyle.ALIGN_LEFT);
+ createCell(wb, row, 6, HSSFCellStyle.ALIGN_RIGHT);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
-
}
/**
@@ -60,12 +56,11 @@ public class Alignment
* @param column the column number to create the cell in
* @param align the alignment for the cell.
*/
- private static void createCell(HSSFWorkbook wb, HSSFRow row, short column, short align)
- {
+ private static void createCell(HSSFWorkbook wb, HSSFRow row, int column, int align) {
HSSFCell cell = row.createCell(column);
cell.setCellValue("Align It");
HSSFCellStyle cellStyle = wb.createCellStyle();
- cellStyle.setAlignment(align);
+ cellStyle.setAlignment((short)align);
cell.setCellStyle(cellStyle);
}
}
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java
index 85894c6474..3981a145da 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -31,12 +29,9 @@ import java.io.IOException;
* @author Glen Stampoultzis (glens at apache.org)
* @author Andrew Oliver (acoliver at apache.org)
*/
-public class BigExample
-{
- public static void main(String[] args)
- throws IOException
- {
- short rownum;
+public class BigExample {
+ public static void main(String[] args) throws IOException {
+ int rownum;
// create a new file
FileOutputStream out = new FileOutputStream("workbook.xls");
@@ -59,7 +54,7 @@ public class BigExample
//set font 1 to 12 point type
f.setFontHeightInPoints((short) 12);
//make it red
- f.setColor((short) HSSFColor.RED.index);
+ f.setColor(HSSFColor.RED.index);
// make it bold
//arial is the default font
f.setBoldweight(f.BOLDWEIGHT_BOLD);
@@ -67,7 +62,7 @@ public class BigExample
//set font 2 to 10 point type
f2.setFontHeightInPoints((short) 10);
//make it the color at palette index 0xf (white)
- f2.setColor((short) HSSFColor.WHITE.index);
+ f2.setColor(HSSFColor.WHITE.index);
//make it bold
f2.setBoldweight(f2.BOLDWEIGHT_BOLD);
@@ -79,9 +74,9 @@ public class BigExample
//set a thin border
cs2.setBorderBottom(cs2.BORDER_THIN);
//fill w fg fill color
- cs2.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND);
+ cs2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
// set foreground fill to red
- cs2.setFillForegroundColor((short) HSSFColor.RED.index);
+ cs2.setFillForegroundColor(HSSFColor.RED.index);
// set the font
cs2.setFont(f2);
@@ -89,7 +84,7 @@ public class BigExample
// set the sheet name to HSSF Test
wb.setSheetName(0, "HSSF Test");
// create a sheet with 300 rows (0-299)
- for (rownum = (short) 0; rownum < 300; rownum++)
+ for (rownum = 0; rownum < 300; rownum++)
{
// create a row
r = s.createRow(rownum);
@@ -102,7 +97,7 @@ public class BigExample
//r.setRowNum(( short ) rownum);
// create 50 cells (0-49) (the += 2 becomes apparent later
- for (short cellnum = (short) 0; cellnum < 50; cellnum += 2)
+ for (int cellnum = 0; cellnum < 50; cellnum += 2)
{
// create a numeric cell
c = r.createCell(cellnum);
@@ -119,12 +114,12 @@ public class BigExample
}
// create a string cell (see why += 2 in the
- c = r.createCell((short) (cellnum + 1));
+ c = r.createCell(cellnum + 1);
// set the cell's string value to "TEST"
c.setCellValue("TEST");
// make this column a bit wider
- s.setColumnWidth((short) (cellnum + 1), (short) ((50 * 8) / ((double) 1 / 20)));
+ s.setColumnWidth(cellnum + 1, (int)((50 * 8) / ((double) 1 / 20)));
// on every other row
if ((rownum % 2) == 0)
@@ -149,8 +144,7 @@ public class BigExample
cs3.setBorderBottom(cs3.BORDER_THICK);
//create 50 cells
- for (short cellnum = (short) 0; cellnum < 50; cellnum++)
- {
+ for (int cellnum =0; cellnum < 50; cellnum++) {
//create a blank type cell (no value)
c = r.createCell(cellnum);
// set it to the thick black border style
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Borders.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Borders.java
index d632cf18b2..d29635004a 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Borders.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Borders.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -30,19 +28,16 @@ import java.io.IOException;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class Borders
-{
- public static void main(String[] args)
- throws IOException
- {
+public class Borders {
+ public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
- HSSFRow row = sheet.createRow((short) 1);
+ HSSFRow row = sheet.createRow(1);
// Create a cell and put a value in it.
- HSSFCell cell = row.createCell((short) 1);
+ HSSFCell cell = row.createCell(1);
cell.setCellValue(4);
// Style the cell with borders all around.
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellComments.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellComments.java
index 7ec606fea3..84efa9cd2d 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellComments.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellComments.java
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.hssf.usermodel.*;
@@ -42,7 +43,7 @@ public class CellComments {
HSSFPatriarch patr = sheet.createDrawingPatriarch();
//create a cell in row 3
- HSSFCell cell1 = sheet.createRow(3).createCell((short)1);
+ HSSFCell cell1 = sheet.createRow(3).createCell(1);
cell1.setCellValue(new HSSFRichTextString("Hello, World"));
//anchor defines size and position of the comment in worksheet
@@ -59,7 +60,7 @@ public class CellComments {
cell1.setCellComment(comment1);
//create another cell in row 6
- HSSFCell cell2 = sheet.createRow(6).createCell((short)1);
+ HSSFCell cell2 = sheet.createRow(6).createCell(1);
cell2.setCellValue(36.6);
@@ -85,7 +86,7 @@ public class CellComments {
/**
* The second way to assign comment to a cell is to implicitly specify its row and column.
* Note, it is possible to set row and column of a non-existing cell.
- * It works, the commnet is visible.
+ * It works, the comment is visible.
*/
comment2.setRow(6);
comment2.setColumn((short)1);
@@ -93,7 +94,5 @@ public class CellComments {
FileOutputStream out = new FileOutputStream("poi_comment.xls");
wb.write(out);
out.close();
-
-
}
}
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java
index dd66747622..07b9b0165a 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -28,19 +26,16 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
-public class CellTypes
-{
- public static void main(String[] args)
- throws IOException
- {
+public class CellTypes {
+ public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
- HSSFRow row = sheet.createRow((short)2);
- row.createCell((short) 0).setCellValue(1.1);
- row.createCell((short) 1).setCellValue(new Date());
- row.createCell((short) 2).setCellValue("a string");
- row.createCell((short) 3).setCellValue(true);
- row.createCell((short) 4).setCellType(HSSFCell.CELL_TYPE_ERROR);
+ HSSFRow row = sheet.createRow(2);
+ row.createCell(0).setCellValue(1.1);
+ row.createCell(1).setCellValue(new Date());
+ row.createCell(2).setCellValue("a string");
+ row.createCell(3).setCellValue(true);
+ row.createCell(4).setCellType(HSSFCell.CELL_TYPE_ERROR);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateCells.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateCells.java
index fb7a773320..ff8a0b73ca 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateCells.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateCells.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -32,24 +30,21 @@ import java.io.IOException;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class CreateCells
-{
- public static void main(String[] args)
- throws IOException
- {
+public class CreateCells {
+ public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
- HSSFRow row = sheet.createRow((short)0);
+ HSSFRow row = sheet.createRow(0);
// Create a cell and put a value in it.
- HSSFCell cell = row.createCell((short)0);
+ HSSFCell cell = row.createCell(0);
cell.setCellValue(1);
// Or do it on one line.
- row.createCell((short)1).setCellValue(1.2);
- row.createCell((short)2).setCellValue("This is a string");
- row.createCell((short)3).setCellValue(true);
+ row.createCell(1).setCellValue(1.2);
+ row.createCell(2).setCellValue("This is a string");
+ row.createCell(3).setCellValue(true);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateDateCells.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateDateCells.java
index fb7908ab8f..746fd536b8 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateDateCells.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateDateCells.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -32,26 +30,23 @@ import java.util.Date;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class CreateDateCells
-{
- public static void main(String[] args)
- throws IOException
- {
+public class CreateDateCells {
+ public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
- HSSFRow row = sheet.createRow((short)0);
+ HSSFRow row = sheet.createRow(0);
// Create a cell and put a date value in it. The first cell is not styled as a date.
- HSSFCell cell = row.createCell((short)0);
+ HSSFCell cell = row.createCell(0);
cell.setCellValue(new Date());
// we style the second cell as a date (and time). It is important to create a new cell style from the workbook
// otherwise you can end up modifying the built in style and effecting not only this cell but other cells.
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
- cell = row.createCell((short)1);
+ cell = row.createCell(1);
cell.setCellValue(new Date());
cell.setCellStyle(cellStyle);
@@ -59,6 +54,5 @@ public class CreateDateCells
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
-
}
}
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/FrillsAndFills.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/FrillsAndFills.java
index c483371563..02b7cb3e39 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/FrillsAndFills.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/FrillsAndFills.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -30,22 +28,19 @@ import java.io.IOException;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class FrillsAndFills
-{
- public static void main(String[] args)
- throws IOException
- {
+public class FrillsAndFills {
+ public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
- HSSFRow row = sheet.createRow((short) 1);
+ HSSFRow row = sheet.createRow(1);
// Aqua background
HSSFCellStyle style = wb.createCellStyle();
style.setFillBackgroundColor(HSSFColor.AQUA.index);
style.setFillPattern(HSSFCellStyle.BIG_SPOTS);
- HSSFCell cell = row.createCell((short) 1);
+ HSSFCell cell = row.createCell(1);
cell.setCellValue("X");
cell.setCellStyle(style);
@@ -53,7 +48,7 @@ public class FrillsAndFills
style = wb.createCellStyle();
style.setFillForegroundColor(HSSFColor.ORANGE.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
- cell = row.createCell((short) 2);
+ cell = row.createCell(2);
cell.setCellValue("X");
cell.setCellStyle(style);
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java
index 81c505a067..8ed9213bfa 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -25,28 +23,22 @@ import java.io.FileOutputStream;
import java.io.IOException;
/**
- * Test if hyperlink formula, with url that got more than 127 charaters, works
+ * Test if hyperlink formula, with url that got more than 127 characters, works
*
* @author Bernard Chesnoy
*/
-public class HyperlinkFormula
-{
- public static void main(String[] args)
- throws IOException
- {
- HSSFCell cell;
-
- HSSFWorkbook wb = new HSSFWorkbook();
+public class HyperlinkFormula {
+ public static void main(String[] args) throws IOException {
+ HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
- HSSFRow row = sheet.createRow((short) 0);
+ HSSFRow row = sheet.createRow(0);
- cell = row.createCell((short)0);
+ HSSFCell cell = row.createCell(0);
cell.setCellType(HSSFCell.CELL_TYPE_FORMULA);
cell.setCellFormula("HYPERLINK(\"http://127.0.0.1:8080/toto/truc/index.html?test=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"test\")");
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
-
}
}
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java
index 24b3f186fc..456df81486 100755
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -35,7 +34,7 @@ public class Hyperlinks {
HSSFWorkbook wb = new HSSFWorkbook();
//cell style for hyperlinks
- //by default hypelrinks are blue and underlined
+ //by default hyperlinks are blue and underlined
HSSFCellStyle hlink_style = wb.createCellStyle();
HSSFFont hlink_font = wb.createFont();
hlink_font.setUnderline(HSSFFont.U_SINGLE);
@@ -46,7 +45,7 @@ public class Hyperlinks {
HSSFSheet sheet = wb.createSheet("Hyperlinks");
//URL
- cell = sheet.createRow(0).createCell((short)0);
+ cell = sheet.createRow(0).createCell(0);
cell.setCellValue("URL Link");
HSSFHyperlink link = new HSSFHyperlink(HSSFHyperlink.LINK_URL);
link.setAddress("http://poi.apache.org/");
@@ -54,7 +53,7 @@ public class Hyperlinks {
cell.setCellStyle(hlink_style);
//link to a file in the current directory
- cell = sheet.createRow(1).createCell((short)0);
+ cell = sheet.createRow(1).createCell(0);
cell.setCellValue("File Link");
link = new HSSFHyperlink(HSSFHyperlink.LINK_FILE);
link.setAddress("link1.xls");
@@ -62,7 +61,7 @@ public class Hyperlinks {
cell.setCellStyle(hlink_style);
//e-mail link
- cell = sheet.createRow(2).createCell((short)0);
+ cell = sheet.createRow(2).createCell(0);
cell.setCellValue("Email Link");
link = new HSSFHyperlink(HSSFHyperlink.LINK_EMAIL);
//note, if subject contains white spaces, make sure they are url-encoded
@@ -74,9 +73,9 @@ public class Hyperlinks {
//create a target sheet and cell
HSSFSheet sheet2 = wb.createSheet("Target Sheet");
- sheet2.createRow(0).createCell((short)0).setCellValue("Target Cell");
+ sheet2.createRow(0).createCell(0).setCellValue("Target Cell");
- cell = sheet.createRow(3).createCell((short)0);
+ cell = sheet.createRow(3).createCell(0);
cell.setCellValue("Worksheet Link");
link = new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT);
link.setAddress("'Target Sheet'!A1");
@@ -86,6 +85,5 @@ public class Hyperlinks {
FileOutputStream out = new FileOutputStream("hssf-links.xls");
wb.write(out);
out.close();
-
}
}
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/MergedCells.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/MergedCells.java
index fa66d76f0a..31e5215b8e 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/MergedCells.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/MergedCells.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,12 +14,11 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.hssf.usermodel.*;
-import org.apache.poi.ss.util.Region;
+import org.apache.poi.ss.util.CellRangeAddress;
import java.io.IOException;
import java.io.FileOutputStream;
@@ -30,24 +28,20 @@ import java.io.FileOutputStream;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class MergedCells
-{
- public static void main(String[] args)
- throws IOException
- {
+public class MergedCells {
+ public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
- HSSFRow row = sheet.createRow((short) 1);
- HSSFCell cell = row.createCell((short) 1);
+ HSSFRow row = sheet.createRow(1);
+ HSSFCell cell = row.createCell(1);
cell.setCellValue("This is a test of merging");
- sheet.addMergedRegion(new Region(1,(short)1,1,(short)2));
+ sheet.addMergedRegion(new CellRangeAddress(1, 1, 1, 2));
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
-
}
}
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java
index e96dc23cab..7653a0b527 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -30,36 +28,32 @@ import java.io.IOException;
* @author Glen Stampoultzis (glens at apache.org)
* @author Fauzia Lala <fauzia.lala at wcom.com>
*/
-public class NewLinesInCells
-{
- public static void main( String[] args ) throws IOException
- {
+public class NewLinesInCells {
+ public static void main( String[] args ) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
- HSSFSheet s = wb.createSheet();
- HSSFRow r = null;
- HSSFCell c = null;
- HSSFCellStyle cs = wb.createCellStyle();
- HSSFFont f = wb.createFont();
- HSSFFont f2 = wb.createFont();
-
- cs = wb.createCellStyle();
-
- cs.setFont( f2 );
- //Word Wrap MUST be turned on
- cs.setWrapText( true );
-
- r = s.createRow( (short) 2 );
- r.setHeight( (short) 0x349 );
- c = r.createCell( (short) 2 );
- c.setCellType( HSSFCell.CELL_TYPE_STRING );
- c.setCellValue( "Use \n with word wrap on to create a new line" );
- c.setCellStyle( cs );
- s.setColumnWidth( (short) 2, (short) ( ( 50 * 8 ) / ( (double) 1 / 20 ) ) );
-
- FileOutputStream fileOut = new FileOutputStream( "workbook.xls" );
- wb.write( fileOut );
- fileOut.close();
-
+ HSSFSheet s = wb.createSheet();
+ HSSFRow r = null;
+ HSSFCell c = null;
+ HSSFCellStyle cs = wb.createCellStyle();
+ HSSFFont f2 = wb.createFont();
+
+ cs = wb.createCellStyle();
+
+ cs.setFont(f2);
+ // Word Wrap MUST be turned on
+ cs.setWrapText(true);
+
+ r = s.createRow(2);
+ r.setHeight((short) 0x349);
+ c = r.createCell(2);
+ c.setCellType(HSSFCell.CELL_TYPE_STRING);
+ c.setCellValue("Use \n with word wrap on to create a new line");
+ c.setCellStyle(cs);
+ s.setColumnWidth(2, (int) ((50 * 8) / ((double) 1 / 20)));
+
+ FileOutputStream fileOut = new FileOutputStream("workbook.xls");
+ wb.write(fileOut);
+ fileOut.close();
}
}
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewSheet.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewSheet.java
index 960c0d9e5d..5fdf2dd30d 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewSheet.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewSheet.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -30,14 +28,12 @@ import java.io.FileOutputStream;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class NewSheet
-{
- public static void main(String[] args)
- throws IOException
- {
+public class NewSheet {
+ public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- HSSFSheet sheet2 = wb.createSheet("second sheet");
+ HSSFSheet sheet2 = wb.createSheet(); // create with default name
+ wb.setSheetName(1, "second sheet"); // setting sheet name later
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java
index 21319f8730..1b580d35f0 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.hssf.usermodel.*;
@@ -27,11 +26,8 @@ import java.io.*;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class OfficeDrawing
-{
- public static void main(String[] args)
- throws IOException
- {
+public class OfficeDrawing {
+ public static void main(String[] args) throws IOException {
// Create the workbook and sheets.
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
@@ -58,8 +54,8 @@ public class OfficeDrawing
// Create a row and size one of the cells reasonably large.
HSSFRow row = sheet1.createRow(2);
row.setHeight((short) 2800);
- row.createCell( (short)1 );
- sheet1.setColumnWidth((short) 2, (short) 9000);
+ row.createCell(1);
+ sheet1.setColumnWidth(2, 9000);
// Create the drawing patriarch. This is the top level container for
// all shapes.
@@ -80,9 +76,9 @@ public class OfficeDrawing
{
// Create a row and size one of the cells reasonably large.
HSSFRow row = sheet2.createRow(2);
- row.createCell( (short)1 );
+ row.createCell(1);
row.setHeightInPoints(240);
- sheet2.setColumnWidth((short) 2, (short) 9000);
+ sheet2.setColumnWidth(2, 9000);
// Create the drawing patriarch. This is the top level container for
// all shapes. This will clear out any existing shapes for that sheet.
@@ -97,8 +93,8 @@ public class OfficeDrawing
// Create a row and size one of the cells reasonably large
HSSFRow row = sheet3.createRow(2);
row.setHeightInPoints(140);
- row.createCell( (short)1 );
- sheet3.setColumnWidth((short) 2, (short) 9000);
+ row.createCell(1);
+ sheet3.setColumnWidth(2, 9000);
// Create the drawing patriarch. This is the top level container for
// all shapes. This will clear out any existing shapes for that sheet.
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java
index 0fb72c6582..4de1207f42 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.hssf.usermodel.*;
@@ -29,15 +28,13 @@ import java.io.IOException;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class OfficeDrawingWithGraphics
-{
- public static void main( String[] args ) throws IOException
- {
+public class OfficeDrawingWithGraphics {
+ public static void main( String[] args ) throws IOException {
// Create a workbook with one sheet and size the first three somewhat
// larger so we can fit the chemical structure diagram in.
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet( "my drawing" );
- sheet.setColumnWidth((short)1, (short)(256 * 27));
+ sheet.setColumnWidth(1, 256 * 27);
HSSFRow row1 = sheet.createRow(0);
row1.setHeightInPoints(10 * 15);
HSSFRow row2 = sheet.createRow(1);
@@ -47,9 +44,9 @@ public class OfficeDrawingWithGraphics
// Add some cells so we can test that the anchoring works when we
// sort them.
- row1.createCell((short)0).setCellValue("C");
- row2.createCell((short)0).setCellValue("A");
- row3.createCell((short)0).setCellValue("B");
+ row1.createCell(0).setCellValue("C");
+ row2.createCell(0).setCellValue("A");
+ row3.createCell(0).setCellValue("B");
// Create the top level drawing patriarch.
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
@@ -62,7 +59,7 @@ public class OfficeDrawingWithGraphics
a = new HSSFClientAnchor( 0, 0, 1023, 255, (short) 1, 0, (short) 1, 0 );
group = patriarch.createGroup( a );
group.setCoordinates( 0, 0, 320, 276 );
- float verticalPointsPerPixel = a.getAnchorHeightInPoints(sheet) / (float)Math.abs(group.getY2() - group.getY1());
+ float verticalPointsPerPixel = a.getAnchorHeightInPoints(sheet) / Math.abs(group.getY2() - group.getY1());
g = new EscherGraphics( group, wb, Color.black, verticalPointsPerPixel );
g2d = new EscherGraphics2d( g );
drawStar( g2d );
@@ -70,7 +67,7 @@ public class OfficeDrawingWithGraphics
a = new HSSFClientAnchor( 0, 0, 1023, 255, (short) 1, 1, (short) 1, 1 );
group = patriarch.createGroup( a );
group.setCoordinates( 0, 0, 640, 276 );
- verticalPointsPerPixel = a.getAnchorHeightInPoints(sheet) / (float)Math.abs(group.getY2() - group.getY1());
+ verticalPointsPerPixel = a.getAnchorHeightInPoints(sheet) / Math.abs(group.getY2() - group.getY1());
// verticalPixelsPerPoint = (float)Math.abs(group.getY2() - group.getY1()) / a.getAnchorHeightInPoints(sheet);
g = new EscherGraphics( group, wb, Color.black, verticalPointsPerPixel );
g2d = new EscherGraphics2d( g );
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Outlines.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Outlines.java
index 4d68f8071c..c04d608ed0 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Outlines.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Outlines.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -29,16 +27,11 @@ import java.io.IOException;
/**
* Creates outlines.
- *
+ *
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class Outlines
-{
- private Outlines(){}
-
- public static void main(String[] args)
- throws IOException
- {
+public class Outlines {
+ public static void main(String[] args) throws IOException {
createCase1( "outline1.xls" );
System.out.println( "outline1.xls written. Two expanded groups." );
createCase2( "outline2.xls" );
@@ -67,19 +60,17 @@ public class Outlines
System.out.println( "outline13.xls written. Mixed bag." );
}
- private static void createCase1( String filename ) throws IOException{
+ private static void createCase1(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupColumn( (short)4, (short)7 );
+ sheet1.groupColumn(4, 7);
- for (int row = 0; row < 200; row++)
- {
- HSSFRow r = sheet1.createRow( row );
- for (int column = 0; column < 200; column++)
- {
- HSSFCell c = r.createCell( (short) column );
- c.setCellValue( column );
+ for (int row = 0; row < 200; row++) {
+ HSSFRow r = sheet1.createRow(row);
+ for (int column = 0; column < 200; column++) {
+ HSSFCell c = r.createCell(column);
+ c.setCellValue(column);
}
}
@@ -88,198 +79,181 @@ public class Outlines
fileOut.close();
}
- private static void createCase2( String filename ) throws IOException{
+ private static void createCase2(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupColumn( (short)2, (short)10 );
- sheet1.groupColumn( (short)4, (short)7 );
- sheet1.setColumnGroupCollapsed( (short)4, true );
+ sheet1.groupColumn(2, 10);
+ sheet1.groupColumn(4, 7);
+ sheet1.setColumnGroupCollapsed(4, true);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
- private static void createCase3( String filename ) throws IOException{
+ private static void createCase3(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupColumn( (short)2, (short)10 );
- sheet1.groupColumn( (short)4, (short)7 );
- sheet1.setColumnGroupCollapsed( (short)4, true );
- sheet1.setColumnGroupCollapsed( (short)2, true );
+ sheet1.groupColumn(2, 10);
+ sheet1.groupColumn(4, 7);
+ sheet1.setColumnGroupCollapsed(4, true);
+ sheet1.setColumnGroupCollapsed(2, true);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
- private static void createCase4( String filename ) throws IOException{
+ private static void createCase4(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupColumn( (short)2, (short)10 );
- sheet1.groupColumn( (short)4, (short)7 );
- sheet1.setColumnGroupCollapsed( (short)4, true );
- sheet1.setColumnGroupCollapsed( (short)2, true );
+ sheet1.groupColumn(2, 10);
+ sheet1.groupColumn(4, 7);
+ sheet1.setColumnGroupCollapsed(4, true);
+ sheet1.setColumnGroupCollapsed(2, true);
- sheet1.setColumnGroupCollapsed( (short)4, false );
+ sheet1.setColumnGroupCollapsed(4, false);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
- private static void createCase5( String filename ) throws IOException{
+ private static void createCase5(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupColumn( (short)2, (short)10 );
- sheet1.groupColumn( (short)4, (short)7 );
- sheet1.setColumnGroupCollapsed( (short)4, true );
- sheet1.setColumnGroupCollapsed( (short)2, true );
+ sheet1.groupColumn(2, 10);
+ sheet1.groupColumn(4, 7);
+ sheet1.setColumnGroupCollapsed(4, true);
+ sheet1.setColumnGroupCollapsed(2, true);
- sheet1.setColumnGroupCollapsed( (short)4, false );
- sheet1.setColumnGroupCollapsed( (short)3, false );
+ sheet1.setColumnGroupCollapsed(4, false);
+ sheet1.setColumnGroupCollapsed(3, false);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
- private static void createCase6( String filename ) throws IOException{
+ private static void createCase6(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupColumn( (short)2, (short)10 );
- sheet1.groupColumn( (short)4, (short)10 );
- sheet1.setColumnGroupCollapsed( (short)4, true );
- sheet1.setColumnGroupCollapsed( (short)2, true );
+ sheet1.groupColumn(2, 10);
+ sheet1.groupColumn(4, 10);
+ sheet1.setColumnGroupCollapsed(4, true);
+ sheet1.setColumnGroupCollapsed(2, true);
- sheet1.setColumnGroupCollapsed( (short)3, false );
+ sheet1.setColumnGroupCollapsed(3, false);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
- private static void createCase7( String filename )
- throws IOException
- {
+ private static void createCase7(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupRow( 5, 14 );
- sheet1.groupRow( 7, 10 );
+ sheet1.groupRow(5, 14);
+ sheet1.groupRow(7, 10);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
- private static void createCase8( String filename )
- throws IOException
- {
+ private static void createCase8(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupRow( 5, 14 );
- sheet1.groupRow( 7, 10 );
- sheet1.setRowGroupCollapsed( 7, true );
+ sheet1.groupRow(5, 14);
+ sheet1.groupRow(7, 10);
+ sheet1.setRowGroupCollapsed(7, true);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
- private static void createCase9( String filename )
- throws IOException
- {
+ private static void createCase9(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupRow( 5, 14 );
- sheet1.groupRow( 7, 10 );
- sheet1.setRowGroupCollapsed( 7, true );
- sheet1.setRowGroupCollapsed( 5, true );
+ sheet1.groupRow(5, 14);
+ sheet1.groupRow(7, 10);
+ sheet1.setRowGroupCollapsed(7, true);
+ sheet1.setRowGroupCollapsed(5, true);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
-
- private static void createCase10( String filename )
- throws IOException
- {
+ private static void createCase10(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupRow( 5, 14 );
- sheet1.groupRow( 7, 10 );
- sheet1.setRowGroupCollapsed( 7, true );
- sheet1.setRowGroupCollapsed( 5, true );
- sheet1.setRowGroupCollapsed( 8, false );
+ sheet1.groupRow(5, 14);
+ sheet1.groupRow(7, 10);
+ sheet1.setRowGroupCollapsed(7, true);
+ sheet1.setRowGroupCollapsed(5, true);
+ sheet1.setRowGroupCollapsed(8, false);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
- private static void createCase11( String filename )
- throws IOException
- {
+ private static void createCase11(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupRow( 5, 14 );
- sheet1.groupRow( 7, 10 );
- sheet1.setRowGroupCollapsed( 7, true );
- sheet1.setRowGroupCollapsed( 5, true );
- sheet1.setRowGroupCollapsed( 8, false );
- sheet1.setRowGroupCollapsed( 14, false );
+ sheet1.groupRow(5, 14);
+ sheet1.groupRow(7, 10);
+ sheet1.setRowGroupCollapsed(7, true);
+ sheet1.setRowGroupCollapsed(5, true);
+ sheet1.setRowGroupCollapsed(8, false);
+ sheet1.setRowGroupCollapsed(14, false);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
- private static void createCase12( String filename )
- throws IOException
- {
+ private static void createCase12(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupRow( 5, 14 );
- sheet1.groupRow( 7, 14 );
- sheet1.setRowGroupCollapsed( 7, true );
- sheet1.setRowGroupCollapsed( 5, true );
- sheet1.setRowGroupCollapsed( 6, false );
+ sheet1.groupRow(5, 14);
+ sheet1.groupRow(7, 14);
+ sheet1.setRowGroupCollapsed(7, true);
+ sheet1.setRowGroupCollapsed(5, true);
+ sheet1.setRowGroupCollapsed(6, false);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
- private static void createCase13( String filename )
- throws IOException
- {
+ private static void createCase13(String filename) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
- sheet1.groupRow( 5, 14 );
- sheet1.groupRow( 7, 14 );
- sheet1.groupRow( 16, 19 );
+ sheet1.groupRow(5, 14);
+ sheet1.groupRow(7, 14);
+ sheet1.groupRow(16, 19);
- sheet1.groupColumn( (short)4, (short)7 );
- sheet1.groupColumn( (short)9, (short)12 );
- sheet1.groupColumn( (short)10, (short)11 );
+ sheet1.groupColumn(4, 7);
+ sheet1.groupColumn(9, 12);
+ sheet1.groupColumn(10, 11);
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
fileOut.close();
}
-
-
}
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java
index 821950fac0..26bba44674 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -35,11 +33,8 @@ import java.io.IOException;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class ReadWriteWorkbook
-{
- public static void main(String[] args)
- throws IOException
- {
+public class ReadWriteWorkbook {
+ public static void main(String[] args) throws IOException {
FileInputStream fileIn = null;
FileOutputStream fileOut = null;
@@ -52,18 +47,16 @@ public class ReadWriteWorkbook
HSSFRow row = sheet.getRow(2);
if (row == null)
row = sheet.createRow(2);
- HSSFCell cell = row.getCell((short)3);
+ HSSFCell cell = row.getCell(3);
if (cell == null)
- cell = row.createCell((short)3);
+ cell = row.createCell(3);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue("a test");
// Write the output to a file
fileOut = new FileOutputStream("workbookout.xls");
wb.write(fileOut);
- }
- finally
- {
+ } finally {
if (fileOut != null)
fileOut.close();
if (fileIn != null)
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/RepeatingRowsAndColumns.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/RepeatingRowsAndColumns.java
index e6fd1eb29b..df4e3bb64c 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/RepeatingRowsAndColumns.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/RepeatingRowsAndColumns.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,34 +14,23 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.hssf.usermodel.*;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import java.io.IOException;
import java.io.FileOutputStream;
-import java.io.FileInputStream;
/**
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class RepeatingRowsAndColumns
-{
- public static void main(String[] args)
- throws IOException
- {
+public class RepeatingRowsAndColumns {
+ public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("first sheet");
- HSSFSheet sheet2 = wb.createSheet("second sheet");
- HSSFSheet sheet3 = wb.createSheet("third sheet");
-
-// POIFSFileSystem fs =
-// new POIFSFileSystem(new FileInputStream("workbook.xls"));
-// HSSFWorkbook wb = new HSSFWorkbook(fs);
-// HSSFSheet sheet1 = wb.getSheetAt(0);
+ wb.createSheet("second sheet");
+ wb.createSheet("third sheet");
HSSFFont boldFont = wb.createFont();
boldFont.setFontHeightInPoints((short)22);
@@ -51,8 +39,8 @@ public class RepeatingRowsAndColumns
HSSFCellStyle boldStyle = wb.createCellStyle();
boldStyle.setFont(boldFont);
- HSSFRow row = sheet1.createRow((short)1);
- HSSFCell cell = row.createCell((short)0);
+ HSSFRow row = sheet1.createRow(1);
+ HSSFCell cell = row.createCell(0);
cell.setCellValue("This quick brown fox");
cell.setCellStyle(boldStyle);
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/WorkingWithFonts.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/WorkingWithFonts.java
index 7276746467..6cb15941f2 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/WorkingWithFonts.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/WorkingWithFonts.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel.examples;
@@ -29,16 +27,13 @@ import java.io.IOException;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class WorkingWithFonts
-{
- public static void main(String[] args)
- throws IOException
- {
+public class WorkingWithFonts {
+ public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
- HSSFRow row = sheet.createRow((short) 1);
+ HSSFRow row = sheet.createRow(1);
// Create a new font and alter it.
HSSFFont font = wb.createFont();
@@ -52,7 +47,7 @@ public class WorkingWithFonts
style.setFont(font);
// Create a cell and put a value in it.
- HSSFCell cell = row.createCell((short) 1);
+ HSSFCell cell = row.createCell(1);
cell.setCellValue("This is a test of fonts");
cell.setCellStyle(style);
@@ -60,6 +55,5 @@ public class WorkingWithFonts
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
-
}
}