aboutsummaryrefslogtreecommitdiffstats
path: root/src/examples
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2016-07-17 11:43:50 +0000
committerJaven O'Neal <onealj@apache.org>2016-07-17 11:43:50 +0000
commitb85400423d4b0551550baa98e836545e08fa773f (patch)
tree946ab7c9a70447429205124c0c5a475203e97e8b /src/examples
parent5b3a1ad4cee1672c0126abc48035a9974d0709b8 (diff)
downloadpoi-b85400423d4b0551550baa98e836545e08fa773f.tar.gz
poi-b85400423d4b0551550baa98e836545e08fa773f.zip
bug 59264,59833,59837: upgrade deprecated methods in examples and testcases
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753060 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/Alignment.java19
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java18
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java50
-rw-r--r--src/examples/src/org/apache/poi/ss/examples/AligningCells.java16
-rw-r--r--src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java63
-rw-r--r--src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java66
-rw-r--r--src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java66
-rw-r--r--src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java15
-rw-r--r--src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java34
-rw-r--r--src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java53
-rw-r--r--src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java26
-rw-r--r--src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java33
12 files changed, 247 insertions, 212 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 46f56d66fa..43fb75db1c 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
@@ -27,6 +27,7 @@ import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
/**
* Shows how various alignment options work.
@@ -38,13 +39,13 @@ public class Alignment {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
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);
+ createCell(wb, row, 0, HorizontalAlignment.CENTER);
+ createCell(wb, row, 1, HorizontalAlignment.CENTER_SELECTION);
+ createCell(wb, row, 2, HorizontalAlignment.FILL);
+ createCell(wb, row, 3, HorizontalAlignment.GENERAL);
+ createCell(wb, row, 4, HorizontalAlignment.JUSTIFY);
+ createCell(wb, row, 5, HorizontalAlignment.LEFT);
+ createCell(wb, row, 6, HorizontalAlignment.RIGHT);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
@@ -62,11 +63,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, int column, int align) {
+ private static void createCell(HSSFWorkbook wb, HSSFRow row, int column, HorizontalAlignment align) {
HSSFCell cell = row.createCell(column);
cell.setCellValue("Align It");
HSSFCellStyle cellStyle = wb.createCellStyle();
- cellStyle.setAlignment((short)align);
+ cellStyle.setAlignment(align);
cell.setCellStyle(cellStyle);
}
}
diff --git a/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java b/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java
index 56d3e58a7d..5a1aca6e97 100644
--- a/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java
+++ b/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java
@@ -129,7 +129,7 @@ public class SVTableCellEditor extends AbstractCellEditor implements TableCellEd
if (cell != null) {
HSSFCellStyle style = cell.getCellStyle();
HSSFFont f = wb.getFontAt(style.getFontIndex());
- boolean isbold = f.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL;
+ boolean isbold = f.getBold();
boolean isitalics = f.getItalic();
int fontstyle = Font.PLAIN;
@@ -172,18 +172,18 @@ public class SVTableCellEditor extends AbstractCellEditor implements TableCellEd
default:
editor.setText("?");
}
- switch (style.getAlignment()) {
- case HSSFCellStyle.ALIGN_LEFT:
- case HSSFCellStyle.ALIGN_JUSTIFY:
- case HSSFCellStyle.ALIGN_FILL:
+ switch (style.getAlignmentEnum()) {
+ case LEFT:
+ case JUSTIFY:
+ case FILL:
editor.setHorizontalAlignment(SwingConstants.LEFT);
break;
- case HSSFCellStyle.ALIGN_CENTER:
- case HSSFCellStyle.ALIGN_CENTER_SELECTION:
+ case CENTER:
+ case CENTER_SELECTION:
editor.setHorizontalAlignment(SwingConstants.CENTER);
break;
- case HSSFCellStyle.ALIGN_GENERAL:
- case HSSFCellStyle.ALIGN_RIGHT:
+ case GENERAL:
+ case RIGHT:
editor.setHorizontalAlignment(SwingConstants.RIGHT);
break;
default:
diff --git a/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java b/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java
index 6f05b09783..ac0075b16b 100644
--- a/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java
+++ b/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java
@@ -19,18 +19,28 @@
package org.apache.poi.hssf.view;
-import javax.swing.*;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.border.*;
-
-import java.awt.Component;
import java.awt.Color;
+import java.awt.Component;
import java.awt.Rectangle;
import java.io.Serializable;
-import java.text.*;
+import java.text.DecimalFormat;
+import java.text.Format;
+import java.text.SimpleDateFormat;
+
+import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+import javax.swing.table.TableCellRenderer;
-import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.hssf.usermodel.HSSFFont;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
/**
@@ -99,14 +109,6 @@ public class SVTableCellRenderer extends JLabel
textFormatter[0x30] = new DecimalFormat("##0.0E0");
}
- public String format(short index, Object value) {
- if (index == 0)
- return value.toString();
- if (textFormatter[index] == null)
- throw new RuntimeException("Sorry. I cant handle the format code :"+Integer.toHexString(index));
- return textFormatter[index].format(value);
- }
-
public String format(short index, double value) {
if ( index <= 0 )
return generalNumberFormat.format(value);
@@ -148,7 +150,7 @@ public class SVTableCellRenderer extends JLabel
HSSFFont f = wb.getFontAt(s.getFontIndex());
setFont(SVTableUtils.makeFont(f));
- if (s.getFillPattern() == HSSFCellStyle.SOLID_FOREGROUND) {
+ if (s.getFillPatternEnum() == FillPatternType.SOLID_FOREGROUND) {
setBackground(SVTableUtils.getAWTColor(s.getFillForegroundColor(), SVTableUtils.white));
} else setBackground(SVTableUtils.white);
@@ -192,18 +194,18 @@ public class SVTableCellRenderer extends JLabel
setValue("?");
}
//Set the text alignment of the cell
- switch (s.getAlignment()) {
- case HSSFCellStyle.ALIGN_LEFT:
- case HSSFCellStyle.ALIGN_JUSTIFY:
- case HSSFCellStyle.ALIGN_FILL:
+ switch (s.getAlignmentEnum()) {
+ case LEFT:
+ case JUSTIFY:
+ case FILL:
setHorizontalAlignment(SwingConstants.LEFT);
break;
- case HSSFCellStyle.ALIGN_CENTER:
- case HSSFCellStyle.ALIGN_CENTER_SELECTION:
+ case CENTER:
+ case CENTER_SELECTION:
setHorizontalAlignment(SwingConstants.CENTER);
break;
- case HSSFCellStyle.ALIGN_GENERAL:
- case HSSFCellStyle.ALIGN_RIGHT:
+ case GENERAL:
+ case RIGHT:
setHorizontalAlignment(SwingConstants.RIGHT);
break;
default:
diff --git a/src/examples/src/org/apache/poi/ss/examples/AligningCells.java b/src/examples/src/org/apache/poi/ss/examples/AligningCells.java
index 80591fd70a..fa8619ae17 100644
--- a/src/examples/src/org/apache/poi/ss/examples/AligningCells.java
+++ b/src/examples/src/org/apache/poi/ss/examples/AligningCells.java
@@ -38,13 +38,13 @@ public class AligningCells {
sheet.setColumnWidth(i, 256 * 15);
}
- createCell(wb, row, (short) 0, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_BOTTOM);
- createCell(wb, row, (short) 1, CellStyle.ALIGN_CENTER_SELECTION, CellStyle.VERTICAL_BOTTOM);
- createCell(wb, row, (short) 2, CellStyle.ALIGN_FILL, CellStyle.VERTICAL_CENTER);
- createCell(wb, row, (short) 3, CellStyle.ALIGN_GENERAL, CellStyle.VERTICAL_CENTER);
- createCell(wb, row, (short) 4, CellStyle.ALIGN_JUSTIFY, CellStyle.VERTICAL_JUSTIFY);
- createCell(wb, row, (short) 5, CellStyle.ALIGN_LEFT, CellStyle.VERTICAL_TOP);
- createCell(wb, row, (short) 6, CellStyle.ALIGN_RIGHT, CellStyle.VERTICAL_TOP);
+ createCell(wb, row, (short) 0, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
+ createCell(wb, row, (short) 1, HorizontalAlignment.CENTER_SELECTION, VerticalAlignment.BOTTOM);
+ createCell(wb, row, (short) 2, HorizontalAlignment.FILL, VerticalAlignment.CENTER);
+ createCell(wb, row, (short) 3, HorizontalAlignment.GENERAL, VerticalAlignment.CENTER);
+ createCell(wb, row, (short) 4, HorizontalAlignment.JUSTIFY, VerticalAlignment.JUSTIFY);
+ createCell(wb, row, (short) 5, HorizontalAlignment.LEFT, VerticalAlignment.TOP);
+ createCell(wb, row, (short) 6, HorizontalAlignment.RIGHT, VerticalAlignment.TOP);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("ss-example-align.xlsx");
@@ -61,7 +61,7 @@ public class AligningCells {
* @param column the column number to create the cell in
* @param halign the horizontal alignment for the cell.
*/
- private static void createCell(Workbook wb, Row row, short column, short halign, short valign) {
+ private static void createCell(Workbook wb, Row row, short column, HorizontalAlignment halign, VerticalAlignment valign) {
CreationHelper ch = wb.getCreationHelper();
Cell cell = row.createCell(column);
cell.setCellValue(ch.createRichTextString("Align It"));
diff --git a/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java b/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java
index 0f98c2b2e2..d263494ec6 100644
--- a/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java
+++ b/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java
@@ -214,114 +214,117 @@ public class BusinessPlan {
CellStyle style;
Font headerFont = wb.createFont();
- headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
+ headerFont.setBold(true);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setFont(headerFont);
styles.put("header", style);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setFont(headerFont);
style.setDataFormat(df.getFormat("d-mmm"));
styles.put("header_date", style);
Font font1 = wb.createFont();
- font1.setBoldweight(Font.BOLDWEIGHT_BOLD);
+ font1.setBold(true);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_LEFT);
+ style.setAlignment(HorizontalAlignment.LEFT);
style.setFont(font1);
styles.put("cell_b", style);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
style.setFont(font1);
styles.put("cell_b_centered", style);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_RIGHT);
+ style.setAlignment(HorizontalAlignment.RIGHT);
style.setFont(font1);
style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_b_date", style);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_RIGHT);
+ style.setAlignment(HorizontalAlignment.RIGHT);
style.setFont(font1);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_g", style);
Font font2 = wb.createFont();
font2.setColor(IndexedColors.BLUE.getIndex());
- font2.setBoldweight(Font.BOLDWEIGHT_BOLD);
+ font2.setBold(true);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_LEFT);
+ style.setAlignment(HorizontalAlignment.LEFT);
style.setFont(font2);
styles.put("cell_bb", style);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_RIGHT);
+ style.setAlignment(HorizontalAlignment.RIGHT);
style.setFont(font1);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_bg", style);
Font font3 = wb.createFont();
font3.setFontHeightInPoints((short)14);
font3.setColor(IndexedColors.DARK_BLUE.getIndex());
- font3.setBoldweight(Font.BOLDWEIGHT_BOLD);
+ font3.setBold(true);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_LEFT);
+ style.setAlignment(HorizontalAlignment.LEFT);
style.setFont(font3);
style.setWrapText(true);
styles.put("cell_h", style);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_LEFT);
+ style.setAlignment(HorizontalAlignment.LEFT);
style.setWrapText(true);
styles.put("cell_normal", style);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
style.setWrapText(true);
styles.put("cell_normal_centered", style);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_RIGHT);
+ style.setAlignment(HorizontalAlignment.RIGHT);
style.setWrapText(true);
style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_normal_date", style);
style = createBorderedStyle(wb);
- style.setAlignment(CellStyle.ALIGN_LEFT);
+ style.setAlignment(HorizontalAlignment.LEFT);
style.setIndention((short)1);
style.setWrapText(true);
styles.put("cell_indented", style);
style = createBorderedStyle(wb);
style.setFillForegroundColor(IndexedColors.BLUE.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
styles.put("cell_blue", style);
return styles;
}
private static CellStyle createBorderedStyle(Workbook wb){
+ BorderStyle thin = BorderStyle.THIN;
+ short black = IndexedColors.BLACK.getIndex();
+
CellStyle style = wb.createCellStyle();
- style.setBorderRight(CellStyle.BORDER_THIN);
- style.setRightBorderColor(IndexedColors.BLACK.getIndex());
- style.setBorderBottom(CellStyle.BORDER_THIN);
- style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
- style.setBorderLeft(CellStyle.BORDER_THIN);
- style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
- style.setBorderTop(CellStyle.BORDER_THIN);
- style.setTopBorderColor(IndexedColors.BLACK.getIndex());
+ style.setBorderRight(thin);
+ style.setRightBorderColor(black);
+ style.setBorderBottom(thin);
+ style.setBottomBorderColor(black);
+ style.setBorderLeft(thin);
+ style.setLeftBorderColor(black);
+ style.setBorderTop(thin);
+ style.setTopBorderColor(black);
return style;
}
}
diff --git a/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java b/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java
index 5512aa04fd..4438f22c15 100644
--- a/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java
+++ b/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java
@@ -157,86 +157,86 @@ public class CalendarDemo {
titleFont.setFontHeightInPoints((short)48);
titleFont.setColor(IndexedColors.DARK_BLUE.getIndex());
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
- style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFont(titleFont);
styles.put("title", style);
Font monthFont = wb.createFont();
monthFont.setFontHeightInPoints((short)12);
monthFont.setColor(IndexedColors.WHITE.getIndex());
- monthFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
+ monthFont.setBold(true);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
- style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setFont(monthFont);
styles.put("month", style);
Font dayFont = wb.createFont();
dayFont.setFontHeightInPoints((short)14);
- dayFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
+ dayFont.setBold(true);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_LEFT);
- style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
+ style.setAlignment(HorizontalAlignment.LEFT);
+ style.setVerticalAlignment(VerticalAlignment.TOP);
style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
- style.setBorderLeft(CellStyle.BORDER_THIN);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+ style.setBorderLeft(BorderStyle.THIN);
style.setLeftBorderColor(borderColor);
- style.setBorderBottom(CellStyle.BORDER_THIN);
+ style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(borderColor);
style.setFont(dayFont);
styles.put("weekend_left", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
- style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.TOP);
style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
- style.setBorderRight(CellStyle.BORDER_THIN);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+ style.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(borderColor);
- style.setBorderBottom(CellStyle.BORDER_THIN);
+ style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(borderColor);
styles.put("weekend_right", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_LEFT);
- style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
- style.setBorderLeft(CellStyle.BORDER_THIN);
+ style.setAlignment(HorizontalAlignment.LEFT);
+ style.setVerticalAlignment(VerticalAlignment.TOP);
+ style.setBorderLeft(BorderStyle.THIN);
style.setFillForegroundColor(IndexedColors.WHITE.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setLeftBorderColor(borderColor);
- style.setBorderBottom(CellStyle.BORDER_THIN);
+ style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(borderColor);
style.setFont(dayFont);
styles.put("workday_left", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
- style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.TOP);
style.setFillForegroundColor(IndexedColors.WHITE.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
- style.setBorderRight(CellStyle.BORDER_THIN);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+ style.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(borderColor);
- style.setBorderBottom(CellStyle.BORDER_THIN);
+ style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(borderColor);
styles.put("workday_right", style);
style = wb.createCellStyle();
- style.setBorderLeft(CellStyle.BORDER_THIN);
+ style.setBorderLeft(BorderStyle.THIN);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
- style.setBorderBottom(CellStyle.BORDER_THIN);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+ style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(borderColor);
styles.put("grey_left", style);
style = wb.createCellStyle();
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
- style.setBorderRight(CellStyle.BORDER_THIN);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+ style.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(borderColor);
- style.setBorderBottom(CellStyle.BORDER_THIN);
+ style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(borderColor);
styles.put("grey_right", style);
diff --git a/src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java b/src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java
index 9598436589..d6375dc436 100644
--- a/src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java
+++ b/src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java
@@ -158,7 +158,7 @@ public class LoanCalculator {
titleFont.setFontName("Trebuchet MS");
style = wb.createCellStyle();
style.setFont(titleFont);
- style.setBorderBottom(CellStyle.BORDER_DOTTED);
+ style.setBorderBottom(BorderStyle.DOTTED);
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
styles.put("title", style);
@@ -166,97 +166,97 @@ public class LoanCalculator {
itemFont.setFontHeightInPoints((short)9);
itemFont.setFontName("Trebuchet MS");
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_LEFT);
+ style.setAlignment(HorizontalAlignment.LEFT);
style.setFont(itemFont);
styles.put("item_left", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_RIGHT);
+ style.setAlignment(HorizontalAlignment.RIGHT);
style.setFont(itemFont);
styles.put("item_right", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_RIGHT);
+ style.setAlignment(HorizontalAlignment.RIGHT);
style.setFont(itemFont);
- style.setBorderRight(CellStyle.BORDER_DOTTED);
+ style.setBorderRight(BorderStyle.DOTTED);
style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderBottom(CellStyle.BORDER_DOTTED);
+ style.setBorderBottom(BorderStyle.DOTTED);
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderLeft(CellStyle.BORDER_DOTTED);
+ style.setBorderLeft(BorderStyle.DOTTED);
style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderTop(CellStyle.BORDER_DOTTED);
+ style.setBorderTop(BorderStyle.DOTTED);
style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setDataFormat(wb.createDataFormat().getFormat("_($* #,##0.00_);_($* (#,##0.00);_($* \"-\"??_);_(@_)"));
styles.put("input_$", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_RIGHT);
+ style.setAlignment(HorizontalAlignment.RIGHT);
style.setFont(itemFont);
- style.setBorderRight(CellStyle.BORDER_DOTTED);
+ style.setBorderRight(BorderStyle.DOTTED);
style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderBottom(CellStyle.BORDER_DOTTED);
+ style.setBorderBottom(BorderStyle.DOTTED);
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderLeft(CellStyle.BORDER_DOTTED);
+ style.setBorderLeft(BorderStyle.DOTTED);
style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderTop(CellStyle.BORDER_DOTTED);
+ style.setBorderTop(BorderStyle.DOTTED);
style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setDataFormat(wb.createDataFormat().getFormat("0.000%"));
styles.put("input_%", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_RIGHT);
+ style.setAlignment(HorizontalAlignment.RIGHT);
style.setFont(itemFont);
- style.setBorderRight(CellStyle.BORDER_DOTTED);
+ style.setBorderRight(BorderStyle.DOTTED);
style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderBottom(CellStyle.BORDER_DOTTED);
+ style.setBorderBottom(BorderStyle.DOTTED);
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderLeft(CellStyle.BORDER_DOTTED);
+ style.setBorderLeft(BorderStyle.DOTTED);
style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderTop(CellStyle.BORDER_DOTTED);
+ style.setBorderTop(BorderStyle.DOTTED);
style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setDataFormat(wb.createDataFormat().getFormat("0"));
styles.put("input_i", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
style.setFont(itemFont);
style.setDataFormat(wb.createDataFormat().getFormat("m/d/yy"));
styles.put("input_d", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_RIGHT);
+ style.setAlignment(HorizontalAlignment.RIGHT);
style.setFont(itemFont);
- style.setBorderRight(CellStyle.BORDER_DOTTED);
+ style.setBorderRight(BorderStyle.DOTTED);
style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderBottom(CellStyle.BORDER_DOTTED);
+ style.setBorderBottom(BorderStyle.DOTTED);
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderLeft(CellStyle.BORDER_DOTTED);
+ style.setBorderLeft(BorderStyle.DOTTED);
style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderTop(CellStyle.BORDER_DOTTED);
+ style.setBorderTop(BorderStyle.DOTTED);
style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setDataFormat(wb.createDataFormat().getFormat("$##,##0.00"));
- style.setBorderBottom(CellStyle.BORDER_DOTTED);
+ style.setBorderBottom(BorderStyle.DOTTED);
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
styles.put("formula_$", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_RIGHT);
+ style.setAlignment(HorizontalAlignment.RIGHT);
style.setFont(itemFont);
- style.setBorderRight(CellStyle.BORDER_DOTTED);
+ style.setBorderRight(BorderStyle.DOTTED);
style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderBottom(CellStyle.BORDER_DOTTED);
+ style.setBorderBottom(BorderStyle.DOTTED);
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderLeft(CellStyle.BORDER_DOTTED);
+ style.setBorderLeft(BorderStyle.DOTTED);
style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setBorderTop(CellStyle.BORDER_DOTTED);
+ style.setBorderTop(BorderStyle.DOTTED);
style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setDataFormat(wb.createDataFormat().getFormat("0"));
- style.setBorderBottom(CellStyle.BORDER_DOTTED);
+ style.setBorderBottom(BorderStyle.DOTTED);
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
styles.put("formula_i", style);
return styles;
diff --git a/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java b/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java
index 0403bc7952..10c3a4a7dc 100644
--- a/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java
+++ b/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java
@@ -27,10 +27,13 @@ import java.util.Map;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
@@ -157,11 +160,11 @@ public class SSPerformanceTest {
headerFont.setFontHeightInPoints((short) 14);
headerFont.setBold(true);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
- style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFont(headerFont);
style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
styles.put("header", style);
Font monthFont = wb.createFont();
@@ -169,10 +172,10 @@ public class SSPerformanceTest {
monthFont.setColor(IndexedColors.RED.getIndex());
monthFont.setBold(true);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
- style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setFont(monthFont);
styles.put("red-bold", style);
diff --git a/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java b/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
index 8093f3c7ce..8ef20fe437 100644
--- a/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
+++ b/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
@@ -167,10 +167,10 @@ public class TimesheetDemo {
CellStyle style;
Font titleFont = wb.createFont();
titleFont.setFontHeightInPoints((short)18);
- titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
+ titleFont.setBold(true);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
- style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFont(titleFont);
styles.put("title", style);
@@ -178,40 +178,40 @@ public class TimesheetDemo {
monthFont.setFontHeightInPoints((short)11);
monthFont.setColor(IndexedColors.WHITE.getIndex());
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
- style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setFont(monthFont);
style.setWrapText(true);
styles.put("header", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
style.setWrapText(true);
- style.setBorderRight(CellStyle.BORDER_THIN);
+ style.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
- style.setBorderLeft(CellStyle.BORDER_THIN);
+ style.setBorderLeft(BorderStyle.THIN);
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
- style.setBorderTop(CellStyle.BORDER_THIN);
+ style.setBorderTop(BorderStyle.THIN);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
- style.setBorderBottom(CellStyle.BORDER_THIN);
+ style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
styles.put("cell", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
- style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
styles.put("formula", style);
style = wb.createCellStyle();
- style.setAlignment(CellStyle.ALIGN_CENTER);
- style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
styles.put("formula_2", style);
diff --git a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java b/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java
index 59cf4180f1..c5fdc1da9a 100644
--- a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java
+++ b/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java
@@ -16,13 +16,6 @@
==================================================================== */
package org.apache.poi.ss.examples.html;
-import org.apache.poi.hssf.usermodel.HSSFFont;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.format.CellFormat;
-import org.apache.poi.ss.format.CellFormatResult;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.FileInputStream;
@@ -38,8 +31,22 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import static org.apache.poi.ss.usermodel.CellStyle.*;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.format.CellFormat;
+import org.apache.poi.ss.format.CellFormatResult;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* This example shows how to display a spreadsheet in HTML using the classes for
@@ -61,18 +68,18 @@ public class ToHtml {
private static final String COL_HEAD_CLASS = "colHeader";
private static final String ROW_HEAD_CLASS = "rowHeader";
- private static final Map<Short, String> ALIGN = mapFor(
- ALIGN_LEFT, "left",
- ALIGN_CENTER, "center",
- ALIGN_RIGHT, "right",
- ALIGN_FILL, "left",
- ALIGN_JUSTIFY, "left",
- ALIGN_CENTER_SELECTION, "center");
+ private static final Map<HorizontalAlignment, String> HALIGN = mapFor(
+ HorizontalAlignment.LEFT, "left",
+ HorizontalAlignment.CENTER, "center",
+ HorizontalAlignment.RIGHT, "right",
+ HorizontalAlignment.FILL, "left",
+ HorizontalAlignment.JUSTIFY, "left",
+ HorizontalAlignment.CENTER_SELECTION, "center");
- private static final Map<Short, String> VERTICAL_ALIGN = mapFor(
- VERTICAL_BOTTOM, "bottom",
- VERTICAL_CENTER, "middle",
- VERTICAL_TOP, "top");
+ private static final Map<VerticalAlignment, String> VALIGN = mapFor(
+ VerticalAlignment.BOTTOM, "bottom",
+ VerticalAlignment.CENTER, "middle",
+ VerticalAlignment.TOP, "top");
private static final Map<BorderStyle, String> BORDER = mapFor(
BorderStyle.DASH_DOT, "dashed 1pt",
@@ -283,8 +290,8 @@ public class ToHtml {
}
private void styleContents(CellStyle style) {
- styleOut("text-align", style.getAlignment(), ALIGN);
- styleOut("vertical-align", style.getAlignment(), VERTICAL_ALIGN);
+ styleOut("text-align", style.getAlignmentEnum(), HALIGN);
+ styleOut("vertical-align", style.getVerticalAlignmentEnum(), VALIGN);
fontStyle(style);
borderStyles(style);
helper.colorStyles(style, out);
@@ -300,7 +307,7 @@ public class ToHtml {
private void fontStyle(CellStyle style) {
Font font = wb.getFontAt(style.getFontIndex());
- if (font.getBoldweight() >= HSSFFont.BOLDWEIGHT_BOLD)
+ if (font.getBold())
out.format(" font-weight: bold;%n");
if (font.getItalic())
out.format(" font-style: italic;%n");
@@ -440,7 +447,7 @@ public class ToHtml {
}
private String tagStyle(Cell cell, CellStyle style) {
- if (style.getAlignment() == ALIGN_GENERAL) {
+ if (style.getAlignmentEnum() == HorizontalAlignment.GENERAL) {
switch (ultimateCellType(cell)) {
case STRING:
return "style=\"text-align: left;\"";
diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java
index 8b385fed14..b210c1301c 100644
--- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java
+++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java
@@ -22,6 +22,8 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
@@ -35,7 +37,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTRowImpl;
*
* Modified by Cristian Petrula, Romania on May 26, 2010
* New method was added centerAcrossSelection to center a column content over
- * one selection using ALIGN_CENTER_SELECTION
+ * one selection using {@link HorizontalAlignment#CENTER_SELECTION}
* To create this method example was change for XSSF only and the previous
* AligningCells.java example has been moved into the SS examples folder.
*/
@@ -52,17 +54,17 @@ public class AligningCells {
sheet.setColumnWidth(i, 256 * 15);
}
- createCell(wb, row, (short) 0, XSSFCellStyle.ALIGN_CENTER, XSSFCellStyle.VERTICAL_BOTTOM);
- createCell(wb, row, (short) 1, XSSFCellStyle.ALIGN_CENTER_SELECTION, XSSFCellStyle.VERTICAL_BOTTOM);
- createCell(wb, row, (short) 2, XSSFCellStyle.ALIGN_FILL, XSSFCellStyle.VERTICAL_CENTER);
- createCell(wb, row, (short) 3, XSSFCellStyle.ALIGN_GENERAL, XSSFCellStyle.VERTICAL_CENTER);
- createCell(wb, row, (short) 4, XSSFCellStyle.ALIGN_JUSTIFY, XSSFCellStyle.VERTICAL_JUSTIFY);
- createCell(wb, row, (short) 5, XSSFCellStyle.ALIGN_LEFT, XSSFCellStyle.VERTICAL_TOP);
- createCell(wb, row, (short) 6, XSSFCellStyle.ALIGN_RIGHT, XSSFCellStyle.VERTICAL_TOP);
+ createCell(wb, row, (short) 0, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
+ createCell(wb, row, (short) 1, HorizontalAlignment.CENTER_SELECTION, VerticalAlignment.BOTTOM);
+ createCell(wb, row, (short) 2, HorizontalAlignment.FILL, VerticalAlignment.CENTER);
+ createCell(wb, row, (short) 3, HorizontalAlignment.GENERAL, VerticalAlignment.CENTER);
+ createCell(wb, row, (short) 4, HorizontalAlignment.JUSTIFY, VerticalAlignment.JUSTIFY);
+ createCell(wb, row, (short) 5, HorizontalAlignment.LEFT, VerticalAlignment.TOP);
+ createCell(wb, row, (short) 6, HorizontalAlignment.RIGHT, VerticalAlignment.TOP);
//center text over B4, C4, D4
row = sheet.createRow((short) 3);
- centerAcrossSelection(wb, row, (short) 1, (short) 3, XSSFCellStyle.VERTICAL_CENTER);
+ centerAcrossSelection(wb, row, (short) 1, (short) 3, VerticalAlignment.CENTER);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("xssf-align.xlsx");
@@ -81,7 +83,7 @@ public class AligningCells {
* @param halign the horizontal alignment for the cell.
*/
private static void createCell(XSSFWorkbook wb, XSSFRow row, short column,
- short halign, short valign) {
+ HorizontalAlignment halign, VerticalAlignment valign) {
XSSFCell cell = row.createCell(column);
cell.setCellValue(new XSSFRichTextString("Align It"));
CellStyle cellStyle = wb.createCellStyle();
@@ -102,11 +104,11 @@ public class AligningCells {
* @author Cristian Petrula, Romania
*/
private static void centerAcrossSelection(XSSFWorkbook wb, XSSFRow row,
- short start_column, short end_column, short valign) {
+ short start_column, short end_column, VerticalAlignment valign) {
// Create cell style with ALIGN_CENTER_SELECTION
XSSFCellStyle cellStyle = wb.createCellStyle();
- cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER_SELECTION);
+ cellStyle.setAlignment(HorizontalAlignment.CENTER_SELECTION);
cellStyle.setVerticalAlignment(valign);
// Create cells over the selected area
diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java
index 074029988e..66bb597623 100644
--- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java
+++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java
@@ -17,17 +17,34 @@
package org.apache.poi.xssf.usermodel.examples;
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Calendar;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import org.apache.poi.openxml4j.opc.internal.ZipHelper;
import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.util.CellReference;
-import org.apache.poi.xssf.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.apache.poi.xssf.usermodel.XSSFDataFormat;
+import org.apache.poi.xssf.usermodel.XSSFFont;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* Demonstrates a workaround you can use to generate large workbooks and avoid OutOfMemory exception.
@@ -103,22 +120,22 @@ public class BigGridDemo {
XSSFDataFormat fmt = wb.createDataFormat();
XSSFCellStyle style1 = wb.createCellStyle();
- style1.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
+ style1.setAlignment(HorizontalAlignment.RIGHT);
style1.setDataFormat(fmt.getFormat("0.0%"));
styles.put("percent", style1);
XSSFCellStyle style2 = wb.createCellStyle();
- style2.setAlignment(XSSFCellStyle.ALIGN_CENTER);
+ style2.setAlignment(HorizontalAlignment.CENTER);
style2.setDataFormat(fmt.getFormat("0.0X"));
styles.put("coeff", style2);
XSSFCellStyle style3 = wb.createCellStyle();
- style3.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
+ style3.setAlignment(HorizontalAlignment.RIGHT);
style3.setDataFormat(fmt.getFormat("$#,##0.00"));
styles.put("currency", style3);
XSSFCellStyle style4 = wb.createCellStyle();
- style4.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
+ style4.setAlignment(HorizontalAlignment.RIGHT);
style4.setDataFormat(fmt.getFormat("mmm dd"));
styles.put("date", style4);
@@ -126,7 +143,7 @@ public class BigGridDemo {
XSSFFont headerFont = wb.createFont();
headerFont.setBold(true);
style5.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
- style5.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
+ style5.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style5.setFont(headerFont);
styles.put("header", style5);