Fix examples and updated documentation

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352556 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Glen Stampoultzis 2002-04-29 11:08:22 +00:00
parent 6b42e9508d
commit f74b254a40
6 changed files with 133 additions and 155 deletions

View File

@ -75,7 +75,8 @@
</p> </p>
<p>Here is some example code (excerpted and adapted from <p>Here is some example code (excerpted and adapted from
org.apache.poi.hssf.dev.HSSF test class):</p> org.apache.poi.hssf.dev.HSSF test class):</p>
<source><![CDATA[ short rownum; <source><![CDATA[
short rownum;
// create a new file // create a new file
FileOutputStream out = new FileOutputStream("workbook.xls"); FileOutputStream out = new FileOutputStream("workbook.xls");
@ -98,7 +99,7 @@
//set font 1 to 12 point type //set font 1 to 12 point type
f.setFontHeightInPoints((short) 12); f.setFontHeightInPoints((short) 12);
//make it red //make it red
f.setColor((short) HSSFCellStyle.RED); f.setColor((short) HSSFColor.RED.index);
// make it bold // make it bold
//arial is the default font //arial is the default font
f.setBoldweight(f.BOLDWEIGHT_BOLD); f.setBoldweight(f.BOLDWEIGHT_BOLD);
@ -106,7 +107,7 @@
//set font 2 to 10 point type //set font 2 to 10 point type
f2.setFontHeightInPoints((short) 10); f2.setFontHeightInPoints((short) 10);
//make it the color at palette index 0xf (white) //make it the color at palette index 0xf (white)
f2.setColor((short) HSSFCellStyle.WHITE); f2.setColor((short) HSSFColor.WHITE.index);
//make it bold //make it bold
f2.setBoldweight(f2.BOLDWEIGHT_BOLD); f2.setBoldweight(f2.BOLDWEIGHT_BOLD);
@ -120,7 +121,7 @@
//fill w fg fill color //fill w fg fill color
cs2.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND); cs2.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND);
// set foreground fill to red // set foreground fill to red
cs2.setFillForegroundColor((short) HSSFCellStyle.RED); cs2.setFillForegroundColor((short) HSSFColor.RED.index);
// set the font // set the font
cs2.setFont(f2); cs2.setFont(f2);

View File

@ -179,13 +179,13 @@
// Style the cell with borders all around. // Style the cell with borders all around.
HSSFCellStyle style = wb.createCellStyle(); HSSFCellStyle style = wb.createCellStyle();
style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBottomBorderColor(HSSFCellStyle.BLACK); style.setBottomBorderColor(HSSFColor.BLACK.index);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setLeftBorderColor(HSSFCellStyle.GREEN); style.setLeftBorderColor(HSSFColor.GREEN.index);
style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setRightBorderColor(HSSFCellStyle.BLUE); style.setRightBorderColor(HSSFColor.BLUE.index);
style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM_DASHED); style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM_DASHED);
style.setTopBorderColor(HSSFCellStyle.AUTOMATIC); style.setTopBorderColor(HSSFColor.BLACK.index);
cell.setCellStyle(style); cell.setCellStyle(style);
// Write the output to a file // Write the output to a file
@ -205,7 +205,7 @@
// Aqua background // Aqua background
HSSFCellStyle style = wb.createCellStyle(); HSSFCellStyle style = wb.createCellStyle();
style.setFillBackgroundColor(HSSFCellStyle.AQUA); style.setFillBackgroundColor(HSSFColor.AQUA.index);
style.setFillPattern(HSSFCellStyle.BIG_SPOTS); style.setFillPattern(HSSFCellStyle.BIG_SPOTS);
HSSFCell cell = row.createCell((short) 1); HSSFCell cell = row.createCell((short) 1);
cell.setCellValue("X"); cell.setCellValue("X");
@ -213,7 +213,7 @@
// Orange "foreground", foreground being the fill foreground not the font color. // Orange "foreground", foreground being the fill foreground not the font color.
style = wb.createCellStyle(); style = wb.createCellStyle();
style.setFillForegroundColor(HSSFCellStyle.ORANGE); style.setFillForegroundColor(HSSFColor.ORANGE.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
cell = row.createCell((short) 2); cell = row.createCell((short) 2);
cell.setCellValue("X"); cell.setCellValue("X");

View File

@ -21,9 +21,8 @@
Finish Charts Finish Charts
</action> </action>
<action context="code"> <action context="code">
Add Formulas. Finish Formulas.
</action> </action>
</actions> </actions>
<actions priority="medium"> <actions priority="medium">

View File

@ -55,6 +55,7 @@
package org.apache.poi.hssf.usermodel.examples; package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
@ -93,7 +94,7 @@ public class BigExample
//set font 1 to 12 point type //set font 1 to 12 point type
f.setFontHeightInPoints((short) 12); f.setFontHeightInPoints((short) 12);
//make it red //make it red
f.setColor((short) HSSFCellStyle.RED); f.setColor((short) HSSFColor.RED.index);
// make it bold // make it bold
//arial is the default font //arial is the default font
f.setBoldweight(f.BOLDWEIGHT_BOLD); f.setBoldweight(f.BOLDWEIGHT_BOLD);
@ -101,7 +102,7 @@ public class BigExample
//set font 2 to 10 point type //set font 2 to 10 point type
f2.setFontHeightInPoints((short) 10); f2.setFontHeightInPoints((short) 10);
//make it the color at palette index 0xf (white) //make it the color at palette index 0xf (white)
f2.setColor((short) HSSFCellStyle.WHITE); f2.setColor((short) HSSFColor.WHITE.index);
//make it bold //make it bold
f2.setBoldweight(f2.BOLDWEIGHT_BOLD); f2.setBoldweight(f2.BOLDWEIGHT_BOLD);
@ -115,7 +116,7 @@ public class BigExample
//fill w fg fill color //fill w fg fill color
cs2.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND); cs2.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND);
// set foreground fill to red // set foreground fill to red
cs2.setFillForegroundColor((short) HSSFCellStyle.RED); cs2.setFillForegroundColor((short) HSSFColor.RED.index);
// set the font // set the font
cs2.setFont(f2); cs2.setFont(f2);

View File

@ -55,6 +55,7 @@
package org.apache.poi.hssf.usermodel.examples; package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
@ -69,31 +70,6 @@ public class Borders
public static void main(String[] args) public static void main(String[] args)
throws IOException throws IOException
{ {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow((short) 1);
// Create a cell and put a value in it.
HSSFCell cell = row.createCell((short) 1);
cell.setCellValue(4);
// Style the cell with borders all around.
HSSFCellStyle style = wb.createCellStyle();
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBottomBorderColor(HSSFCellStyle.BLACK);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setLeftBorderColor(HSSFCellStyle.GREEN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setRightBorderColor(HSSFCellStyle.BLUE);
style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM_DASHED);
style.setTopBorderColor(HSSFCellStyle.AUTOMATIC);
cell.setCellStyle(style);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
} }
} }

View File

@ -55,6 +55,7 @@
package org.apache.poi.hssf.usermodel.examples; package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
@ -77,7 +78,7 @@ public class FrillsAndFills
// Aqua background // Aqua background
HSSFCellStyle style = wb.createCellStyle(); HSSFCellStyle style = wb.createCellStyle();
style.setFillBackgroundColor(HSSFCellStyle.AQUA); style.setFillBackgroundColor(HSSFColor.AQUA.index);
style.setFillPattern(HSSFCellStyle.BIG_SPOTS); style.setFillPattern(HSSFCellStyle.BIG_SPOTS);
HSSFCell cell = row.createCell((short) 1); HSSFCell cell = row.createCell((short) 1);
cell.setCellValue("X"); cell.setCellValue("X");
@ -85,7 +86,7 @@ public class FrillsAndFills
// Orange "foreground", foreground being the fill foreground not the font color. // Orange "foreground", foreground being the fill foreground not the font color.
style = wb.createCellStyle(); style = wb.createCellStyle();
style.setFillForegroundColor(HSSFCellStyle.ORANGE); style.setFillForegroundColor(HSSFColor.ORANGE.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
cell = row.createCell((short) 2); cell = row.createCell((short) 2);
cell.setCellValue("X"); cell.setCellValue("X");