poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r782402 [4/8] - in /poi/tags/REL_3_5_BETA6: ./ src/contrib/src/org/apache/poi/contrib/poibrowser/ src/documentation/ src/documentation/content/xdocs/ src/documentation/content/xdocs/hpsf/ src/documentation/content/xdocs/news/ src/documentat...
Date Sun, 07 Jun 2009 15:39:55 GMT
Modified: poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java (original)
+++ poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java Sun Jun  7 15:39:51 2009
@@ -1,219 +1,220 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.ss.examples;
-
-import org.apache.poi.xssf.usermodel.*;
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.io.FileOutputStream;
-
-/**
- * A weekly timesheet created using Apache POI.
- * Usage:
- *  TimesheetDemo -xls|xlsx
- *
- * @author Yegor Kozlov
- */
-public class TimesheetDemo {
-    private static final String[] titles = {
-            "Person",	"ID", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
-            "Total\nHrs", "Overtime\nHrs", "Regular\nHrs"
-    };
-
-    private static Object[][] sample_data = {
-            {"Yegor Kozlov", "YK", 5.0, 8.0, 10.0, 5.0, 5.0, 7.0, 6.0},
-            {"Gisella Bronzetti", "GB", 4.0, 3.0, 1.0, 3.5, null, null, 4.0},
-    };
-
-    public static void main(String[] args) throws Exception {
-        Workbook wb;
-
-        if(args.length > 0 && args[0].equals("-xls")) wb = new HSSFWorkbook();
-        else wb = new XSSFWorkbook();
-
-        Map<String, CellStyle> styles = createStyles(wb);
-
-        Sheet sheet = wb.createSheet("Timesheet");
-        PrintSetup printSetup = sheet.getPrintSetup();
-        printSetup.setLandscape(true);
-        sheet.setFitToPage(true);
-        sheet.setHorizontallyCenter(true);
-
-        //title row
-        Row titleRow = sheet.createRow(0);
-        titleRow.setHeightInPoints(45);
-        Cell titleCell = titleRow.createCell(0);
-        titleCell.setCellValue("Weekly Timesheet");
-        titleCell.setCellStyle(styles.get("title"));
-        sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$L$1"));
-
-        //header row
-        Row headerRow = sheet.createRow(1);
-        headerRow.setHeightInPoints(40);
-        Cell headerCell;
-        for (int i = 0; i < titles.length; i++) {
-            headerCell = headerRow.createCell(i);
-            headerCell.setCellValue(titles[i]);
-            headerCell.setCellStyle(styles.get("header"));
-        }
-
-        int rownum = 2;
-        for (int i = 0; i < 10; i++) {
-            Row row = sheet.createRow(rownum++);
-            for (int j = 0; j < titles.length; j++) {
-                Cell cell = row.createCell(j);
-                if(j == 9){
-                    //the 10th cell contains sum over week days, e.g. SUM(C3:I3)
-                    String ref = "C" +rownum+ ":I" + rownum;
-                    cell.setCellFormula("SUM("+ref+")");
-                    cell.setCellStyle(styles.get("formula"));
-                } else if (j == 11){
-                    cell.setCellFormula("J" +rownum+ "-K" + rownum);
-                    cell.setCellStyle(styles.get("formula"));
-                } else {
-                    cell.setCellStyle(styles.get("cell"));
-                }
-            }
-        }
-
-        //row with totals below
-        Row sumRow = sheet.createRow(rownum++);
-        sumRow.setHeightInPoints(35);
-        Cell cell;
-        cell = sumRow.createCell(0);
-        cell.setCellStyle(styles.get("formula"));
-        cell = sumRow.createCell(1);
-        cell.setCellValue("Total Hrs:");
-        cell.setCellStyle(styles.get("formula"));
-
-        for (int j = 2; j < 12; j++) {
-            cell = sumRow.createCell(j);
-            String ref = (char)('A' + j) + "3:" + (char)('A' + j) + "12";
-            cell.setCellFormula("SUM(" + ref + ")");
-            if(j >= 9) cell.setCellStyle(styles.get("formula_2"));
-            else cell.setCellStyle(styles.get("formula"));
-        }
-        rownum++;
-        sumRow = sheet.createRow(rownum++);
-        sumRow.setHeightInPoints(25);
-        cell = sumRow.createCell(0);
-        cell.setCellValue("Total Regular Hours");
-        cell.setCellStyle(styles.get("formula"));
-        cell = sumRow.createCell(1);
-        cell.setCellFormula("L13");
-        cell.setCellStyle(styles.get("formula_2"));
-        sumRow = sheet.createRow(rownum++);
-        sumRow.setHeightInPoints(25);
-        cell = sumRow.createCell(0);
-        cell.setCellValue("Total Overtime Hours");
-        cell.setCellStyle(styles.get("formula"));
-        cell = sumRow.createCell(1);
-        cell.setCellFormula("K13");
-        cell.setCellStyle(styles.get("formula_2"));
-
-        //set sample data
-        for (int i = 0; i < sample_data.length; i++) {
-            Row row = sheet.getRow(2 + i);
-            for (int j = 0; j < sample_data[i].length; j++) {
-                if(sample_data[i][j] == null) continue;
-
-                if(sample_data[i][j] instanceof String) {
-                    row.getCell(j).setCellValue((String)sample_data[i][j]);
-                } else {
-                    row.getCell(j).setCellValue((Double)sample_data[i][j]);
-                }
-            }
-        }
-
-        //finally set column widths, the width is measured in units of 1/256th of a character width
-        sheet.setColumnWidth(0, 30*256); //30 characters wide
-        for (int i = 2; i < 9; i++) {
-            sheet.setColumnWidth(i, 6*256);  //6 characters wide
-        }
-        sheet.setColumnWidth(10, 10*256); //10 characters wide
-
-        // Write the output to a file
-        String file = "timesheet.xls";
-        if(wb instanceof XSSFWorkbook) file += "x";
-        FileOutputStream out = new FileOutputStream(file);
-        wb.write(out);
-        out.close();
-    }
-
-    /**
-     * Create a library of cell styles
-     */
-    private static Map<String, CellStyle> createStyles(Workbook wb){
-        Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
-        CellStyle style;
-        Font titleFont = wb.createFont();
-        titleFont.setFontHeightInPoints((short)18);
-        titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
-        style = wb.createCellStyle();
-        style.setAlignment(CellStyle.ALIGN_CENTER);
-        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
-        style.setFont(titleFont);
-        styles.put("title", style);
-
-        Font monthFont = wb.createFont();
-        monthFont.setFontHeightInPoints((short)11);
-        monthFont.setColor(IndexedColors.WHITE.getIndex());
-        style = wb.createCellStyle();
-        style.setAlignment(CellStyle.ALIGN_CENTER);
-        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
-        style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
-        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
-        style.setFont(monthFont);
-        style.setWrapText(true);
-        styles.put("header", style);
-
-        style = wb.createCellStyle();
-        style.setAlignment(CellStyle.ALIGN_CENTER);
-        style.setWrapText(true);
-        style.setBorderRight(CellStyle.BORDER_THIN);
-        style.setRightBorderColor(IndexedColors.BLACK.getIndex());
-        style.setBorderLeft(CellStyle.BORDER_THIN);
-        style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
-        style.setBorderTop(CellStyle.BORDER_THIN);
-        style.setTopBorderColor(IndexedColors.BLACK.getIndex());
-        style.setBorderBottom(CellStyle.BORDER_THIN);
-        style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
-        styles.put("cell", style);
-
-        style = wb.createCellStyle();
-        style.setAlignment(CellStyle.ALIGN_CENTER);
-        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
-        style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
-        style.setFillPattern(CellStyle.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.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
-        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
-        style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
-        styles.put("formula_2", style);
-
-        return styles;
-    }
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.ss.examples;
+
+import org.apache.poi.xssf.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.io.FileOutputStream;
+
+/**
+ * A weekly timesheet created using Apache POI.
+ * Usage:
+ *  TimesheetDemo -xls|xlsx
+ *
+ * @author Yegor Kozlov
+ */
+public class TimesheetDemo {
+    private static final String[] titles = {
+            "Person",	"ID", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
+            "Total\nHrs", "Overtime\nHrs", "Regular\nHrs"
+    };
+
+    private static Object[][] sample_data = {
+            {"Yegor Kozlov", "YK", 5.0, 8.0, 10.0, 5.0, 5.0, 7.0, 6.0},
+            {"Gisella Bronzetti", "GB", 4.0, 3.0, 1.0, 3.5, null, null, 4.0},
+    };
+
+    public static void main(String[] args) throws Exception {
+        Workbook wb;
+
+        if(args.length > 0 && args[0].equals("-xls")) wb = new HSSFWorkbook();
+        else wb = new XSSFWorkbook();
+
+        Map<String, CellStyle> styles = createStyles(wb);
+
+        Sheet sheet = wb.createSheet("Timesheet");
+        PrintSetup printSetup = sheet.getPrintSetup();
+        printSetup.setLandscape(true);
+        sheet.setFitToPage(true);
+        sheet.setHorizontallyCenter(true);
+
+        //title row
+        Row titleRow = sheet.createRow(0);
+        titleRow.setHeightInPoints(45);
+        Cell titleCell = titleRow.createCell(0);
+        titleCell.setCellValue("Weekly Timesheet");
+        titleCell.setCellStyle(styles.get("title"));
+        sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$L$1"));
+
+        //header row
+        Row headerRow = sheet.createRow(1);
+        headerRow.setHeightInPoints(40);
+        Cell headerCell;
+        for (int i = 0; i < titles.length; i++) {
+            headerCell = headerRow.createCell(i);
+            headerCell.setCellValue(titles[i]);
+            headerCell.setCellStyle(styles.get("header"));
+        }
+
+        int rownum = 2;
+        for (int i = 0; i < 10; i++) {
+            Row row = sheet.createRow(rownum++);
+            for (int j = 0; j < titles.length; j++) {
+                Cell cell = row.createCell(j);
+                if(j == 9){
+                    //the 10th cell contains sum over week days, e.g. SUM(C3:I3)
+                    String ref = "C" +rownum+ ":I" + rownum;
+                    cell.setCellFormula("SUM("+ref+")");
+                    cell.setCellStyle(styles.get("formula"));
+                } else if (j == 11){
+                    cell.setCellFormula("J" +rownum+ "-K" + rownum);
+                    cell.setCellStyle(styles.get("formula"));
+                } else {
+                    cell.setCellStyle(styles.get("cell"));
+                }
+            }
+        }
+
+        //row with totals below
+        Row sumRow = sheet.createRow(rownum++);
+        sumRow.setHeightInPoints(35);
+        Cell cell;
+        cell = sumRow.createCell(0);
+        cell.setCellStyle(styles.get("formula"));
+        cell = sumRow.createCell(1);
+        cell.setCellValue("Total Hrs:");
+        cell.setCellStyle(styles.get("formula"));
+
+        for (int j = 2; j < 12; j++) {
+            cell = sumRow.createCell(j);
+            String ref = (char)('A' + j) + "3:" + (char)('A' + j) + "12";
+            cell.setCellFormula("SUM(" + ref + ")");
+            if(j >= 9) cell.setCellStyle(styles.get("formula_2"));
+            else cell.setCellStyle(styles.get("formula"));
+        }
+        rownum++;
+        sumRow = sheet.createRow(rownum++);
+        sumRow.setHeightInPoints(25);
+        cell = sumRow.createCell(0);
+        cell.setCellValue("Total Regular Hours");
+        cell.setCellStyle(styles.get("formula"));
+        cell = sumRow.createCell(1);
+        cell.setCellFormula("L13");
+        cell.setCellStyle(styles.get("formula_2"));
+        sumRow = sheet.createRow(rownum++);
+        sumRow.setHeightInPoints(25);
+        cell = sumRow.createCell(0);
+        cell.setCellValue("Total Overtime Hours");
+        cell.setCellStyle(styles.get("formula"));
+        cell = sumRow.createCell(1);
+        cell.setCellFormula("K13");
+        cell.setCellStyle(styles.get("formula_2"));
+
+        //set sample data
+        for (int i = 0; i < sample_data.length; i++) {
+            Row row = sheet.getRow(2 + i);
+            for (int j = 0; j < sample_data[i].length; j++) {
+                if(sample_data[i][j] == null) continue;
+
+                if(sample_data[i][j] instanceof String) {
+                    row.getCell(j).setCellValue((String)sample_data[i][j]);
+                } else {
+                    row.getCell(j).setCellValue((Double)sample_data[i][j]);
+                }
+            }
+        }
+
+        //finally set column widths, the width is measured in units of 1/256th of a character width
+        sheet.setColumnWidth(0, 30*256); //30 characters wide
+        for (int i = 2; i < 9; i++) {
+            sheet.setColumnWidth(i, 6*256);  //6 characters wide
+        }
+        sheet.setColumnWidth(10, 10*256); //10 characters wide
+
+        // Write the output to a file
+        String file = "timesheet.xls";
+        if(wb instanceof XSSFWorkbook) file += "x";
+        FileOutputStream out = new FileOutputStream(file);
+        wb.write(out);
+        out.close();
+    }
+
+    /**
+     * Create a library of cell styles
+     */
+    private static Map<String, CellStyle> createStyles(Workbook wb){
+        Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
+        CellStyle style;
+        Font titleFont = wb.createFont();
+        titleFont.setFontHeightInPoints((short)18);
+        titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
+        style = wb.createCellStyle();
+        style.setAlignment(CellStyle.ALIGN_CENTER);
+        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+        style.setFont(titleFont);
+        styles.put("title", style);
+
+        Font monthFont = wb.createFont();
+        monthFont.setFontHeightInPoints((short)11);
+        monthFont.setColor(IndexedColors.WHITE.getIndex());
+        style = wb.createCellStyle();
+        style.setAlignment(CellStyle.ALIGN_CENTER);
+        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+        style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
+        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+        style.setFont(monthFont);
+        style.setWrapText(true);
+        styles.put("header", style);
+
+        style = wb.createCellStyle();
+        style.setAlignment(CellStyle.ALIGN_CENTER);
+        style.setWrapText(true);
+        style.setBorderRight(CellStyle.BORDER_THIN);
+        style.setRightBorderColor(IndexedColors.BLACK.getIndex());
+        style.setBorderLeft(CellStyle.BORDER_THIN);
+        style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
+        style.setBorderTop(CellStyle.BORDER_THIN);
+        style.setTopBorderColor(IndexedColors.BLACK.getIndex());
+        style.setBorderBottom(CellStyle.BORDER_THIN);
+        style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
+        styles.put("cell", style);
+
+        style = wb.createCellStyle();
+        style.setAlignment(CellStyle.ALIGN_CENTER);
+        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+        style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+        style.setFillPattern(CellStyle.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.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
+        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+        style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
+        styles.put("formula_2", style);
+
+        return styles;
+    }
+}

Modified: poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java (original)
+++ poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java Sun Jun  7 15:39:51 2009
@@ -1,73 +1,72 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.xssf.usermodel.examples;
-
-import org.apache.poi.xssf.usermodel.*;
-import org.apache.poi.ss.usermodel.*;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STHorizontalAlignment;
-
-import java.io.FileOutputStream;
-
-/**
- * Shows how various alignment options work.
- */
-public class AligningCells {
-
-    public static void main(String[] args)  throws Exception {
-        Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
-
-        Sheet sheet = wb.createSheet();
-        Row row = sheet.createRow((short) 2);
-        row.setHeightInPoints(30);
-        for (int i = 0; i < 8; i++) {
-            //column width is set in units of 1/256th of a character width
-            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);
-
-        // Write the output to a file
-        FileOutputStream fileOut = new FileOutputStream("xssf-align.xlsx");
-        wb.write(fileOut);
-        fileOut.close();
-
-    }
-
-    /**
-     * Creates a cell and aligns it a certain way.
-     *
-     * @param wb     the workbook
-     * @param row    the row to create the cell in
-     * @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) {
-        Cell cell = row.createCell(column);
-        cell.setCellValue(new XSSFRichTextString("Align It"));
-        CellStyle cellStyle = wb.createCellStyle();
-        cellStyle.setAlignment(halign);
-        cellStyle.setVerticalAlignment(valign);
-        cell.setCellStyle(cellStyle);
-    }
-
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel.examples;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.*;
+
+/**
+ * Shows how various alignment options work.
+ */
+public class AligningCells {
+
+    public static void main(String[] args)  throws IOException {
+        Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
+
+        Sheet sheet = wb.createSheet();
+        Row row = sheet.createRow((short) 2);
+        row.setHeightInPoints(30);
+        for (int i = 0; i < 8; i++) {
+            //column width is set in units of 1/256th of a character width
+            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);
+
+        // Write the output to a file
+        FileOutputStream fileOut = new FileOutputStream("xssf-align.xlsx");
+        wb.write(fileOut);
+        fileOut.close();
+    }
+
+    /**
+     * Creates a cell and aligns it a certain way.
+     *
+     * @param wb     the workbook
+     * @param row    the row to create the cell in
+     * @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) {
+        Cell cell = row.createCell(column);
+        cell.setCellValue(new XSSFRichTextString("Align It"));
+        CellStyle cellStyle = wb.createCellStyle();
+        cellStyle.setAlignment(halign);
+        cellStyle.setVerticalAlignment(valign);
+        cell.setCellStyle(cellStyle);
+    }
+}

Modified: poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java (original)
+++ poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java Sun Jun  7 15:39:51 2009
@@ -1,252 +1,254 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.xssf.usermodel.examples;
-
-import org.apache.poi.xssf.usermodel.*;
-import org.apache.poi.ss.util.CellReference;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import org.apache.poi.ss.usermodel.DateUtil;
-
-import java.io.*;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-import java.util.*;
-
-/**
- * Demonstrates a workaround you can use to generate large workbooks and avoid OutOfMemory exception.
- *
- * The trick is as follows:
- * 1. create a template workbook, create sheets and global objects such as cell styles, number formats, etc.
- * 2. create an application that streams data in a text file
- * 3. Substitute the sheet in the template with the generated data
- *
- * @author Yegor Kozlov
- */
-public class BigGridDemo {
-    public static void main(String[] args) throws Exception {
-
-        // Step 1. Create a template file. Setup sheets and workbook-level objects such as
-        // cell styles, number formats, etc.
-
-        XSSFWorkbook wb = new XSSFWorkbook();
-        XSSFSheet sheet = wb.createSheet("Big Grid");
-
-        Map<String, XSSFCellStyle> styles = createStyles(wb);
-        //name of the zip entry holding sheet data, e.g. /xl/worksheets/sheet1.xml
-        String sheetRef = sheet.getPackagePart().getPartName().getName();
-
-        //save the template
-        FileOutputStream os = new FileOutputStream("template.xlsx");
-        wb.write(os);
-        os.close();
-
-        //Step 2. Generate XML file.
-        File tmp = File.createTempFile("sheet", ".xml");
-        Writer fw = new FileWriter(tmp);
-        generate(fw, styles);
-        fw.close();
-
-        //Step 3. Substitute the template entry with the generated data
-        FileOutputStream out = new FileOutputStream("big-grid.xlsx");
-        substitute(new File("template.xlsx"), tmp, sheetRef.substring(1), out);
-        out.close();
-    }
-
-    /**
-     * Create a library of cell styles.
-     */
-    private static Map<String, XSSFCellStyle> createStyles(XSSFWorkbook wb){
-        Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>();
-        XSSFDataFormat fmt = wb.createDataFormat();
-
-        XSSFCellStyle style1 = wb.createCellStyle();
-        style1.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
-        style1.setDataFormat(fmt.getFormat("0.0%"));
-        styles.put("percent", style1);
-
-        XSSFCellStyle style2 = wb.createCellStyle();
-        style2.setAlignment(XSSFCellStyle.ALIGN_CENTER);
-        style2.setDataFormat(fmt.getFormat("0.0X"));
-        styles.put("coeff", style2);
-
-        XSSFCellStyle style3 = wb.createCellStyle();
-        style3.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
-        style3.setDataFormat(fmt.getFormat("$#,##0.00"));
-        styles.put("currency", style3);
-
-        XSSFCellStyle style4 = wb.createCellStyle();
-        style4.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
-        style4.setDataFormat(fmt.getFormat("mmm dd"));
-        styles.put("date", style4);
-
-        XSSFCellStyle style5 = wb.createCellStyle();
-        XSSFFont headerFont = wb.createFont();
-        headerFont.setBold(true);
-        style5.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
-        style5.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
-        style5.setFont(headerFont);
-        styles.put("header", style5);
-
-        return styles;
-    }
-
-    private static void generate(Writer out, Map<String, XSSFCellStyle> styles) throws Exception {
-
-        Random rnd = new Random();
-        Calendar calendar = Calendar.getInstance();
-
-        SpreadsheetWriter sw = new SpreadsheetWriter(out);
-        sw.beginSheet();
-
-        //insert header row
-        sw.insertRow(0);
-        int styleIndex = styles.get("header").getIndex();
-        sw.createCell(0, "Title", styleIndex);
-        sw.createCell(1, "% Change", styleIndex);
-        sw.createCell(2, "Ratio", styleIndex);
-        sw.createCell(3, "Expenses", styleIndex);
-        sw.createCell(4, "Date", styleIndex);
-
-        sw.endRow();
-
-        //write data rows
-        for (int rownum = 1; rownum < 100000; rownum++) {
-            sw.insertRow(rownum);
-
-            sw.createCell(0, "Hello, " + rownum + "!");
-            sw.createCell(1, (double)rnd.nextInt(100)/100, styles.get("percent").getIndex());
-            sw.createCell(2, (double)rnd.nextInt(10)/10, styles.get("coeff").getIndex());
-            sw.createCell(3, rnd.nextInt(10000), styles.get("currency").getIndex());
-            sw.createCell(4, calendar, styles.get("date").getIndex());
-
-            sw.endRow();
-
-            calendar.roll(Calendar.DAY_OF_YEAR, 1);
-        }
-        sw.endSheet();
-    }
-
-    /**
-     *
-     * @param zipfile the template file
-     * @param tmpfile the XML file with the sheet data
-     * @param entry the name of the sheet entry to substitute, e.g. xl/worksheets/sheet1.xml
-     * @param out the stream to write the result to
-     */
-    private static void substitute(File zipfile, File tmpfile, String entry, OutputStream out) throws IOException {
-        ZipFile zip = new ZipFile(zipfile);
-
-        ZipOutputStream zos = new ZipOutputStream(out);
-
-        for (Enumeration en = zip.entries(); en.hasMoreElements(); ) {
-            ZipEntry ze = (ZipEntry)en.nextElement();
-            if(!ze.getName().equals(entry)){
-                zos.putNextEntry(new ZipEntry(ze.getName()));
-                InputStream is = zip.getInputStream(ze);
-                copyStream(is, zos);
-                is.close();
-            }
-        }
-        zos.putNextEntry(new ZipEntry(entry));
-        InputStream is = new FileInputStream(tmpfile);
-        copyStream(is, zos);
-        is.close();
-
-        zos.close();
-    }
-
-    private static void copyStream(InputStream in, OutputStream out) throws IOException {
-        byte[] chunk = new byte[1024];
-        int count;
-        while ((count = in.read(chunk)) >=0 ) {
-          out.write(chunk,0,count);
-        }
-    }
-
-    /**
-     * Writes spreadsheet data in a Writer.
-     * (YK: in future it may evolve in a full-featured API for streaming data in Excel)
-     */
-    public static class SpreadsheetWriter {
-        private Writer out;
-        private int rownum;
-
-        public SpreadsheetWriter(Writer out){
-            this.out = out;
-        }
-
-        public void beginSheet() throws IOException {
-            out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                    "<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">" );
-            out.write("<sheetData>\n");
-        }
-
-        public void endSheet() throws IOException {
-            out.write("</sheetData>");
-            out.write("</worksheet>");
-        }
-
-        /**
-         * Insert a new row
-         *
-         * @param rownum 0-based row number
-         */
-        public void insertRow(int rownum) throws IOException {
-            out.write("<row r=\""+(rownum+1)+"\">\n");
-            this.rownum = rownum;
-        }
-
-        /**
-         * Insert row end marker
-         */
-        public void endRow() throws IOException {
-            out.write("</row>\n");
-        }
-
-        public void createCell(int columnIndex, String value, int styleIndex) throws IOException {
-            String ref = new CellReference(rownum, columnIndex).formatAsString();
-            out.write("<c r=\""+ref+"\" t=\"inlineStr\"");
-            if(styleIndex != -1) out.write(" s=\""+styleIndex+"\"");
-            out.write(">");
-            out.write("<is><t>"+value+"</t></is>");
-            out.write("</c>");
-        }
-
-        public void createCell(int columnIndex, String value) throws IOException {
-            createCell(columnIndex, value, -1);
-        }
-
-        public void createCell(int columnIndex, double value, int styleIndex) throws IOException {
-            String ref = new CellReference(rownum, columnIndex).formatAsString();
-            out.write("<c r=\""+ref+"\" t=\"n\"");
-            if(styleIndex != -1) out.write(" s=\""+styleIndex+"\"");
-            out.write(">");
-            out.write("<v>"+value+"</v>");
-            out.write("</c>");
-        }
-
-        public void createCell(int columnIndex, double value) throws IOException {
-            createCell(columnIndex, value, -1);
-        }
-
-        public void createCell(int columnIndex, Calendar value, int styleIndex) throws IOException {
-            createCell(columnIndex, DateUtil.getExcelDate(value, false), styleIndex);
-        }
-    }
-
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel.examples;
+
+import java.io.*;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.xssf.usermodel.*;
+
+/**
+ * Demonstrates a workaround you can use to generate large workbooks and avoid OutOfMemory exception.
+ *
+ * The trick is as follows:
+ * 1. create a template workbook, create sheets and global objects such as cell styles, number formats, etc.
+ * 2. create an application that streams data in a text file
+ * 3. Substitute the sheet in the template with the generated data
+ *
+ * @author Yegor Kozlov
+ */
+public class BigGridDemo {
+    public static void main(String[] args) throws Exception {
+
+        // Step 1. Create a template file. Setup sheets and workbook-level objects such as
+        // cell styles, number formats, etc.
+
+        XSSFWorkbook wb = new XSSFWorkbook();
+        XSSFSheet sheet = wb.createSheet("Big Grid");
+
+        Map<String, XSSFCellStyle> styles = createStyles(wb);
+        //name of the zip entry holding sheet data, e.g. /xl/worksheets/sheet1.xml
+        String sheetRef = sheet.getPackagePart().getPartName().getName();
+
+        //save the template
+        FileOutputStream os = new FileOutputStream("template.xlsx");
+        wb.write(os);
+        os.close();
+
+        //Step 2. Generate XML file.
+        File tmp = File.createTempFile("sheet", ".xml");
+        Writer fw = new FileWriter(tmp);
+        generate(fw, styles);
+        fw.close();
+
+        //Step 3. Substitute the template entry with the generated data
+        FileOutputStream out = new FileOutputStream("big-grid.xlsx");
+        substitute(new File("template.xlsx"), tmp, sheetRef.substring(1), out);
+        out.close();
+    }
+
+    /**
+     * Create a library of cell styles.
+     */
+    private static Map<String, XSSFCellStyle> createStyles(XSSFWorkbook wb){
+        Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>();
+        XSSFDataFormat fmt = wb.createDataFormat();
+
+        XSSFCellStyle style1 = wb.createCellStyle();
+        style1.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
+        style1.setDataFormat(fmt.getFormat("0.0%"));
+        styles.put("percent", style1);
+
+        XSSFCellStyle style2 = wb.createCellStyle();
+        style2.setAlignment(XSSFCellStyle.ALIGN_CENTER);
+        style2.setDataFormat(fmt.getFormat("0.0X"));
+        styles.put("coeff", style2);
+
+        XSSFCellStyle style3 = wb.createCellStyle();
+        style3.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
+        style3.setDataFormat(fmt.getFormat("$#,##0.00"));
+        styles.put("currency", style3);
+
+        XSSFCellStyle style4 = wb.createCellStyle();
+        style4.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
+        style4.setDataFormat(fmt.getFormat("mmm dd"));
+        styles.put("date", style4);
+
+        XSSFCellStyle style5 = wb.createCellStyle();
+        XSSFFont headerFont = wb.createFont();
+        headerFont.setBold(true);
+        style5.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+        style5.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
+        style5.setFont(headerFont);
+        styles.put("header", style5);
+
+        return styles;
+    }
+
+    private static void generate(Writer out, Map<String, XSSFCellStyle> styles) throws Exception {
+
+        Random rnd = new Random();
+        Calendar calendar = Calendar.getInstance();
+
+        SpreadsheetWriter sw = new SpreadsheetWriter(out);
+        sw.beginSheet();
+
+        //insert header row
+        sw.insertRow(0);
+        int styleIndex = styles.get("header").getIndex();
+        sw.createCell(0, "Title", styleIndex);
+        sw.createCell(1, "% Change", styleIndex);
+        sw.createCell(2, "Ratio", styleIndex);
+        sw.createCell(3, "Expenses", styleIndex);
+        sw.createCell(4, "Date", styleIndex);
+
+        sw.endRow();
+
+        //write data rows
+        for (int rownum = 1; rownum < 100000; rownum++) {
+            sw.insertRow(rownum);
+
+            sw.createCell(0, "Hello, " + rownum + "!");
+            sw.createCell(1, (double)rnd.nextInt(100)/100, styles.get("percent").getIndex());
+            sw.createCell(2, (double)rnd.nextInt(10)/10, styles.get("coeff").getIndex());
+            sw.createCell(3, rnd.nextInt(10000), styles.get("currency").getIndex());
+            sw.createCell(4, calendar, styles.get("date").getIndex());
+
+            sw.endRow();
+
+            calendar.roll(Calendar.DAY_OF_YEAR, 1);
+        }
+        sw.endSheet();
+    }
+
+    /**
+     *
+     * @param zipfile the template file
+     * @param tmpfile the XML file with the sheet data
+     * @param entry the name of the sheet entry to substitute, e.g. xl/worksheets/sheet1.xml
+     * @param out the stream to write the result to
+     */
+	private static void substitute(File zipfile, File tmpfile, String entry, OutputStream out) throws IOException {
+        ZipFile zip = new ZipFile(zipfile);
+
+        ZipOutputStream zos = new ZipOutputStream(out);
+
+        @SuppressWarnings("unchecked")
+        Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
+        while (en.hasMoreElements()) {
+            ZipEntry ze = en.nextElement();
+            if(!ze.getName().equals(entry)){
+                zos.putNextEntry(new ZipEntry(ze.getName()));
+                InputStream is = zip.getInputStream(ze);
+                copyStream(is, zos);
+                is.close();
+            }
+        }
+        zos.putNextEntry(new ZipEntry(entry));
+        InputStream is = new FileInputStream(tmpfile);
+        copyStream(is, zos);
+        is.close();
+
+        zos.close();
+    }
+
+    private static void copyStream(InputStream in, OutputStream out) throws IOException {
+        byte[] chunk = new byte[1024];
+        int count;
+        while ((count = in.read(chunk)) >=0 ) {
+          out.write(chunk,0,count);
+        }
+    }
+
+    /**
+     * Writes spreadsheet data in a Writer.
+     * (YK: in future it may evolve in a full-featured API for streaming data in Excel)
+     */
+    public static class SpreadsheetWriter {
+        private final Writer _out;
+        private int _rownum;
+
+        public SpreadsheetWriter(Writer out){
+            _out = out;
+        }
+
+        public void beginSheet() throws IOException {
+            _out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+                    "<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">" );
+            _out.write("<sheetData>\n");
+        }
+
+        public void endSheet() throws IOException {
+            _out.write("</sheetData>");
+            _out.write("</worksheet>");
+        }
+
+        /**
+         * Insert a new row
+         *
+         * @param rownum 0-based row number
+         */
+        public void insertRow(int rownum) throws IOException {
+            _out.write("<row r=\""+(rownum+1)+"\">\n");
+            this._rownum = rownum;
+        }
+
+        /**
+         * Insert row end marker
+         */
+        public void endRow() throws IOException {
+            _out.write("</row>\n");
+        }
+
+        public void createCell(int columnIndex, String value, int styleIndex) throws IOException {
+            String ref = new CellReference(_rownum, columnIndex).formatAsString();
+            _out.write("<c r=\""+ref+"\" t=\"inlineStr\"");
+            if(styleIndex != -1) _out.write(" s=\""+styleIndex+"\"");
+            _out.write(">");
+            _out.write("<is><t>"+value+"</t></is>");
+            _out.write("</c>");
+        }
+
+        public void createCell(int columnIndex, String value) throws IOException {
+            createCell(columnIndex, value, -1);
+        }
+
+        public void createCell(int columnIndex, double value, int styleIndex) throws IOException {
+            String ref = new CellReference(_rownum, columnIndex).formatAsString();
+            _out.write("<c r=\""+ref+"\" t=\"n\"");
+            if(styleIndex != -1) _out.write(" s=\""+styleIndex+"\"");
+            _out.write(">");
+            _out.write("<v>"+value+"</v>");
+            _out.write("</c>");
+        }
+
+        public void createCell(int columnIndex, double value) throws IOException {
+            createCell(columnIndex, value, -1);
+        }
+
+        public void createCell(int columnIndex, Calendar value, int styleIndex) throws IOException {
+            createCell(columnIndex, DateUtil.getExcelDate(value, false), styleIndex);
+        }
+    }
+}

Modified: poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java (original)
+++ poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java Sun Jun  7 15:39:51 2009
@@ -1,227 +1,228 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.xssf.usermodel.examples;
-
-import org.apache.poi.xssf.usermodel.*;
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.usermodel.*;
-
-import java.io.FileOutputStream;
-import java.util.Calendar;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * A  monthly calendar created using Apache POI. Each month is on a separate sheet.
- * This is a version of org.apache.poi.ss.examples.CalendarDemo that demonstrates
- * some XSSF features not avaiable when using common HSSF-XSSF interfaces.
- *
- * <pre>
- * Usage:
- * CalendarDemo <year>
- * </pre>
- *
- * @author Yegor Kozlov
- */
-public class CalendarDemo {
-
-    private static final String[] days = {
-            "Sunday", "Monday", "Tuesday",
-            "Wednesday", "Thursday", "Friday", "Saturday"};
-
-    private static final String[]  months = {
-            "January", "February", "March","April", "May", "June","July", "August",
-            "September","October", "November", "December"};
-
-    public static void main(String[] args) throws Exception {
-
-        Calendar calendar = Calendar.getInstance();
-        if(args.length > 0) calendar.set(Calendar.YEAR, Integer.parseInt(args[0]));
-
-        int year = calendar.get(Calendar.YEAR);
-
-        XSSFWorkbook wb = new XSSFWorkbook();
-        Map<String, XSSFCellStyle> styles = createStyles(wb);
-
-        for (int month = 0; month < 12; month++) {
-            calendar.set(Calendar.MONTH, month);
-            calendar.set(Calendar.DAY_OF_MONTH, 1);
-            //create a sheet for each month
-            XSSFSheet sheet = wb.createSheet(months[month]);
-
-            //turn off gridlines
-            sheet.setDisplayGridlines(false);
-            sheet.setPrintGridlines(false);
-            XSSFPrintSetup printSetup = sheet.getPrintSetup();
-            printSetup.setOrientation(PrintOrientation.LANDSCAPE);
-            sheet.setFitToPage(true);
-            sheet.setHorizontallyCenter(true);
-
-            //the header row: centered text in 48pt font
-            XSSFRow headerRow = sheet.createRow(0);
-            headerRow.setHeightInPoints(80);
-            XSSFCell titleCell = headerRow.createCell(0);
-            titleCell.setCellValue(months[month] + " " + year);
-            titleCell.setCellStyle(styles.get("title"));
-            sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$N$1"));
-
-            //header with month titles
-            XSSFRow monthRow = sheet.createRow(1);
-            for (int i = 0; i < days.length; i++) {
-                //for compatibility with HSSF we have to set column width in units of 1/256th of a character width
-                sheet.setColumnWidth(i*2, 5*256); //the column is 5 characters wide
-                sheet.setColumnWidth(i*2 + 1, 13*256); //the column is 13 characters wide
-                sheet.addMergedRegion(new CellRangeAddress(1, 1, i*2, i*2+1));
-                XSSFCell monthCell = monthRow.createCell(i*2);
-                monthCell.setCellValue(days[i]);
-                monthCell.setCellStyle(styles.get("month"));
-            }
-
-            int cnt = 1, day=1;
-            int rownum = 2;
-            for (int j = 0; j < 6; j++) {
-                XSSFRow row = sheet.createRow(rownum++);
-                row.setHeightInPoints(100);
-                for (int i = 0; i < days.length; i++) {
-                    XSSFCell dayCell_1 = row.createCell(i*2);
-                    XSSFCell dayCell_2 = row.createCell(i*2 + 1);
-
-                    int day_of_week = calendar.get(Calendar.DAY_OF_WEEK);
-                    if(cnt >= day_of_week && calendar.get(Calendar.MONTH) == month) {
-                        dayCell_1.setCellValue(day);
-                        calendar.set(Calendar.DAY_OF_MONTH, ++day);
-
-                        if(i == 0 || i == days.length-1) {
-                            dayCell_1.setCellStyle(styles.get("weekend_left"));
-                            dayCell_2.setCellStyle(styles.get("weekend_right"));
-                        } else {
-                            dayCell_1.setCellStyle(styles.get("workday_left"));
-                            dayCell_2.setCellStyle(styles.get("workday_right"));
-                        }
-                    } else {
-                        dayCell_1.setCellStyle(styles.get("grey_left"));
-                        dayCell_2.setCellStyle(styles.get("grey_right"));
-                    }
-                    cnt++;
-                }
-                if(calendar.get(Calendar.MONTH) > month) break;
-            }
-        }
-
-        // Write the output to a file
-        FileOutputStream out = new FileOutputStream("calendar-"+year+".xlsx");
-        wb.write(out);
-        out.close();
-    }
-
-    /**
-     * cell styles used for formatting calendar sheets
-     */
-    private static Map<String, XSSFCellStyle> createStyles(XSSFWorkbook wb){
-        Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>();
-
-        XSSFCellStyle style;
-        XSSFFont titleFont = wb.createFont();
-        titleFont.setFontHeightInPoints((short)48);
-        titleFont.setColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        style = wb.createCellStyle();
-        style.setAlignment(HorizontalAlignment.CENTER);
-        style.setVerticalAlignment(VerticalAlignment.CENTER);
-        style.setFont(titleFont);
-        styles.put("title", style);
-
-        XSSFFont monthFont = wb.createFont();
-        monthFont.setFontHeightInPoints((short)12);
-        monthFont.setColor(new XSSFColor(new java.awt.Color(255, 255, 255)));
-        monthFont.setBold(true);
-        style = wb.createCellStyle();
-        style.setAlignment(HorizontalAlignment.CENTER);
-        style.setVerticalAlignment(VerticalAlignment.CENTER);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
-        style.setFont(monthFont);
-        styles.put("month", style);
-
-        XSSFFont dayFont = wb.createFont();
-        dayFont.setFontHeightInPoints((short)14);
-        dayFont.setBold(true);
-        style = wb.createCellStyle();
-        style.setAlignment(HorizontalAlignment.LEFT);
-        style.setVerticalAlignment(VerticalAlignment.TOP);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(228, 232, 243)));
-        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
-        style.setBorderLeft(BorderStyle.THIN);
-        style.setLeftBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        style.setFont(dayFont);
-        styles.put("weekend_left", style);
-
-        style = wb.createCellStyle();
-        style.setAlignment(HorizontalAlignment.CENTER);
-        style.setVerticalAlignment(VerticalAlignment.TOP);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(228, 232, 243)));
-        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
-        style.setBorderRight(BorderStyle.THIN);
-        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        styles.put("weekend_right", style);
-
-        style = wb.createCellStyle();
-        style.setAlignment(HorizontalAlignment.LEFT);
-        style.setVerticalAlignment(VerticalAlignment.TOP);
-        style.setBorderLeft(BorderStyle.THIN);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 255)));
-        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
-        style.setLeftBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        style.setFont(dayFont);
-        styles.put("workday_left", style);
-
-        style = wb.createCellStyle();
-        style.setAlignment(HorizontalAlignment.CENTER);
-        style.setVerticalAlignment(VerticalAlignment.TOP);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 255)));
-        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
-        style.setBorderRight(BorderStyle.THIN);
-        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        styles.put("workday_right", style);
-
-        style = wb.createCellStyle();
-        style.setBorderLeft(BorderStyle.THIN);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(234, 234, 234)));
-        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
-        style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        styles.put("grey_left", style);
-
-        style = wb.createCellStyle();
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(234, 234, 234)));
-        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
-        style.setBorderRight(BorderStyle.THIN);
-        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
-        styles.put("grey_right", style);
-
-        return styles;
-    }
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel.examples;
+
+import org.apache.poi.xssf.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.usermodel.*;
+
+import java.io.FileOutputStream;
+import java.util.Calendar;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * A  monthly calendar created using Apache POI. Each month is on a separate sheet.
+ * This is a version of org.apache.poi.ss.examples.CalendarDemo that demonstrates
+ * some XSSF features not avaiable when using common HSSF-XSSF interfaces.
+ *
+ * <pre>
+ * Usage:
+ * CalendarDemo <year>
+ * </pre>
+ *
+ * @author Yegor Kozlov
+ */
+public class CalendarDemo {
+
+    private static final String[] days = {
+            "Sunday", "Monday", "Tuesday",
+            "Wednesday", "Thursday", "Friday", "Saturday"};
+
+    private static final String[]  months = {
+            "January", "February", "March","April", "May", "June","July", "August",
+            "September","October", "November", "December"};
+
+    public static void main(String[] args) throws Exception {
+
+        Calendar calendar = Calendar.getInstance();
+        if(args.length > 0) calendar.set(Calendar.YEAR, Integer.parseInt(args[0]));
+
+        int year = calendar.get(Calendar.YEAR);
+
+        XSSFWorkbook wb = new XSSFWorkbook();
+        Map<String, XSSFCellStyle> styles = createStyles(wb);
+
+        for (int month = 0; month < 12; month++) {
+            calendar.set(Calendar.MONTH, month);
+            calendar.set(Calendar.DAY_OF_MONTH, 1);
+            //create a sheet for each month
+            XSSFSheet sheet = wb.createSheet(months[month]);
+
+            //turn off gridlines
+            sheet.setDisplayGridlines(false);
+            sheet.setPrintGridlines(false);
+            XSSFPrintSetup printSetup = sheet.getPrintSetup();
+            printSetup.setOrientation(PrintOrientation.LANDSCAPE);
+            sheet.setFitToPage(true);
+            sheet.setHorizontallyCenter(true);
+
+            //the header row: centered text in 48pt font
+            XSSFRow headerRow = sheet.createRow(0);
+            headerRow.setHeightInPoints(80);
+            XSSFCell titleCell = headerRow.createCell(0);
+            titleCell.setCellValue(months[month] + " " + year);
+            titleCell.setCellStyle(styles.get("title"));
+            sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$N$1"));
+
+            //header with month titles
+            XSSFRow monthRow = sheet.createRow(1);
+            for (int i = 0; i < days.length; i++) {
+                //for compatibility with HSSF we have to set column width in units of 1/256th of a character width
+                sheet.setColumnWidth(i*2, 5*256); //the column is 5 characters wide
+                sheet.setColumnWidth(i*2 + 1, 13*256); //the column is 13 characters wide
+                sheet.addMergedRegion(new CellRangeAddress(1, 1, i*2, i*2+1));
+                XSSFCell monthCell = monthRow.createCell(i*2);
+                monthCell.setCellValue(days[i]);
+                monthCell.setCellStyle(styles.get("month"));
+            }
+
+            int cnt = 1, day=1;
+            int rownum = 2;
+            for (int j = 0; j < 6; j++) {
+                XSSFRow row = sheet.createRow(rownum++);
+                row.setHeightInPoints(100);
+                for (int i = 0; i < days.length; i++) {
+                    XSSFCell dayCell_1 = row.createCell(i*2);
+                    XSSFCell dayCell_2 = row.createCell(i*2 + 1);
+
+                    int day_of_week = calendar.get(Calendar.DAY_OF_WEEK);
+                    if(cnt >= day_of_week && calendar.get(Calendar.MONTH) == month) {
+                        dayCell_1.setCellValue(day);
+                        calendar.set(Calendar.DAY_OF_MONTH, ++day);
+
+                        if(i == 0 || i == days.length-1) {
+                            dayCell_1.setCellStyle(styles.get("weekend_left"));
+                            dayCell_2.setCellStyle(styles.get("weekend_right"));
+                        } else {
+                            dayCell_1.setCellStyle(styles.get("workday_left"));
+                            dayCell_2.setCellStyle(styles.get("workday_right"));
+                        }
+                    } else {
+                        dayCell_1.setCellStyle(styles.get("grey_left"));
+                        dayCell_2.setCellStyle(styles.get("grey_right"));
+                    }
+                    cnt++;
+                }
+                if(calendar.get(Calendar.MONTH) > month) break;
+            }
+        }
+
+        // Write the output to a file
+        FileOutputStream out = new FileOutputStream("calendar-"+year+".xlsx");
+        wb.write(out);
+        out.close();
+    }
+
+    /**
+     * cell styles used for formatting calendar sheets
+     */
+    private static Map<String, XSSFCellStyle> createStyles(XSSFWorkbook wb){
+        Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>();
+
+        XSSFCellStyle style;
+        XSSFFont titleFont = wb.createFont();
+        titleFont.setFontHeightInPoints((short)48);
+        titleFont.setColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style = wb.createCellStyle();
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        style.setFont(titleFont);
+        styles.put("title", style);
+
+        XSSFFont monthFont = wb.createFont();
+        monthFont.setFontHeightInPoints((short)12);
+        monthFont.setColor(new XSSFColor(new java.awt.Color(255, 255, 255)));
+        monthFont.setBold(true);
+        style = wb.createCellStyle();
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setFont(monthFont);
+        styles.put("month", style);
+
+        XSSFFont dayFont = wb.createFont();
+        dayFont.setFontHeightInPoints((short)14);
+        dayFont.setBold(true);
+        style = wb.createCellStyle();
+        style.setAlignment(HorizontalAlignment.LEFT);
+        style.setVerticalAlignment(VerticalAlignment.TOP);
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(228, 232, 243)));
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setLeftBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setFont(dayFont);
+        styles.put("weekend_left", style);
+
+        style = wb.createCellStyle();
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.TOP);
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(228, 232, 243)));
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        styles.put("weekend_right", style);
+
+        style = wb.createCellStyle();
+        style.setAlignment(HorizontalAlignment.LEFT);
+        style.setVerticalAlignment(VerticalAlignment.TOP);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 255)));
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setLeftBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setFont(dayFont);
+        styles.put("workday_left", style);
+
+        style = wb.createCellStyle();
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.TOP);
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 255)));
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        styles.put("workday_right", style);
+
+        style = wb.createCellStyle();
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(234, 234, 234)));
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        styles.put("grey_left", style);
+
+        style = wb.createCellStyle();
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(234, 234, 234)));
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        styles.put("grey_right", style);
+
+        return styles;
+    }
+}

Modified: poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java (original)
+++ poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java Sun Jun  7 15:39:51 2009
@@ -21,7 +21,6 @@
 import java.util.Date;
 
 import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.XSSFRichTextString;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 /**

Modified: poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java (original)
+++ poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java Sun Jun  7 15:39:51 2009
@@ -1,44 +1,44 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.xssf.usermodel.examples;
-
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Row;
-
-/**
- *  Iterate over rows and cells
- */
-public class IterateCells {
-
-    public static void main(String[] args) throws Exception {
-        Workbook wb = new XSSFWorkbook(args[0]);
-        for (int i = 0; i < wb.getNumberOfSheets(); i++) {
-            Sheet sheet = wb.getSheetAt(i);
-            System.out.println(wb.getSheetName(i));
-            for (Row row : sheet) {
-                System.out.println("rownum: " + row.getRowNum());
-                for (Cell cell : row) {
-                    System.out.println(cell.toString());
-                }
-            }
-        }
-
-    }
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel.examples;
+
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+
+/**
+ *  Iterate over rows and cells
+ */
+public class IterateCells {
+
+    public static void main(String[] args) throws Exception {
+        Workbook wb = new XSSFWorkbook(args[0]);
+        for (int i = 0; i < wb.getNumberOfSheets(); i++) {
+            Sheet sheet = wb.getSheetAt(i);
+            System.out.println(wb.getSheetName(i));
+            for (Row row : sheet) {
+                System.out.println("rownum: " + row.getRowNum());
+                for (Cell cell : row) {
+                    System.out.println(cell.toString());
+                }
+            }
+        }
+    }
+}

Modified: poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java (original)
+++ poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java Sun Jun  7 15:39:51 2009
@@ -1,50 +1,49 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.xssf.usermodel.examples;
-
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.xssf.usermodel.XSSFRichTextString;
-import org.apache.poi.hssf.util.Region;
-
-import java.io.FileOutputStream;
-
-/**
- * An example of how to merge regions of cells.
- */
-public class MergingCells {
-    public static void main(String[] args) throws Exception {
-        Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
-        Sheet sheet = wb.createSheet("new sheet");
-
-        Row row = sheet.createRow((short) 1);
-        Cell cell = row.createCell((short) 1);
-        cell.setCellValue(new XSSFRichTextString("This is a test of merging"));
-
-        sheet.addMergedRegion(new CellRangeAddress(1, 1, 1, 2));
-
-        // Write the output to a file
-        FileOutputStream fileOut = new FileOutputStream("merging_cells.xlsx");
-        wb.write(fileOut);
-        fileOut.close();
-
-    }
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel.examples;
+
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+
+import java.io.FileOutputStream;
+
+/**
+ * An example of how to merge regions of cells.
+ */
+public class MergingCells {
+    public static void main(String[] args) throws Exception {
+        Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
+        Sheet sheet = wb.createSheet("new sheet");
+
+        Row row = sheet.createRow((short) 1);
+        Cell cell = row.createCell((short) 1);
+        cell.setCellValue(new XSSFRichTextString("This is a test of merging"));
+
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 1, 2));
+
+        // Write the output to a file
+        FileOutputStream fileOut = new FileOutputStream("merging_cells.xlsx");
+        wb.write(fileOut);
+        fileOut.close();
+    }
+}

Modified: poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java (original)
+++ poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java Sun Jun  7 15:39:51 2009
@@ -21,14 +21,13 @@
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 
 public class SelectedSheet {
 
     public static void main(String[]args) throws Exception {
         Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
-        Sheet sheet = wb.createSheet("row sheet");
 
+        Sheet sheet = wb.createSheet("row sheet");
         Sheet sheet2 = wb.createSheet("another sheet");
         Sheet sheet3 = wb.createSheet(" sheet 3 ");
         sheet3.setSelected(true);

Modified: poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/SplitAndFreezePanes.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/SplitAndFreezePanes.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/SplitAndFreezePanes.java (original)
+++ poi/tags/REL_3_5_BETA6/src/examples/src/org/apache/poi/xssf/usermodel/examples/SplitAndFreezePanes.java Sun Jun  7 15:39:51 2009
@@ -1,50 +1,50 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.xssf.usermodel.examples;
-
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-
-import java.io.FileOutputStream;
-
-/**
- * How to set spklit and freeze panes
- */
-public class SplitAndFreezePanes {
-    public static void main(String[]args) throws Exception {
-        Workbook wb = new XSSFWorkbook();
-        Sheet sheet1 = wb.createSheet("new sheet");
-        Sheet sheet2 = wb.createSheet("second sheet");
-        Sheet sheet3 = wb.createSheet("third sheet");
-        Sheet sheet4 = wb.createSheet("fourth sheet");
-
-        // Freeze just one row
-        sheet1.createFreezePane(0, 1, 0, 1);
-        // Freeze just one column
-        sheet2.createFreezePane(1, 0, 1, 0);
-        // Freeze the columns and rows (forget about scrolling position of the lower right quadrant).
-        sheet3.createFreezePane(2, 2);
-        // Create a split with the lower left side being the active quadrant
-        sheet4.createSplitPane(2000, 2000, 0, 0, Sheet.PANE_LOWER_LEFT);
-
-        FileOutputStream fileOut = new FileOutputStream("splitFreezePane.xlsx");
-        wb.write(fileOut);
-        fileOut.close();
-
-    }
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel.examples;
+
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.io.FileOutputStream;
+
+/**
+ * How to set spklit and freeze panes
+ */
+public class SplitAndFreezePanes {
+    public static void main(String[]args) throws Exception {
+        Workbook wb = new XSSFWorkbook();
+        Sheet sheet1 = wb.createSheet("new sheet");
+        Sheet sheet2 = wb.createSheet("second sheet");
+        Sheet sheet3 = wb.createSheet("third sheet");
+        Sheet sheet4 = wb.createSheet("fourth sheet");
+
+        // Freeze just one row
+        sheet1.createFreezePane(0, 1, 0, 1);
+        // Freeze just one column
+        sheet2.createFreezePane(1, 0, 1, 0);
+        // Freeze the columns and rows (forget about scrolling position of the lower right quadrant).
+        sheet3.createFreezePane(2, 2);
+        // Create a split with the lower left side being the active quadrant
+        sheet4.createSplitPane(2000, 2000, 0, 0, Sheet.PANE_LOWER_LEFT);
+
+        FileOutputStream fileOut = new FileOutputStream("splitFreezePane.xlsx");
+        wb.write(fileOut);
+        fileOut.close();
+    }
+}



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


Mime
View raw message