From bb124077b5420d4112213235a4fa72c1fff635f8 Mon Sep 17 00:00:00 2001 From: Glen Stampoultzis Date: Sat, 30 Mar 2002 06:12:30 +0000 Subject: [PATCH] How-to code examples fix. git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352298 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/xdocs/hssf/how-to.xml | 262 +++++++++++------------- 1 file changed, 120 insertions(+), 142 deletions(-) diff --git a/src/documentation/xdocs/hssf/how-to.xml b/src/documentation/xdocs/hssf/how-to.xml index d642f6152b..5e9aa71d5e 100644 --- a/src/documentation/xdocs/hssf/how-to.xml +++ b/src/documentation/xdocs/hssf/how-to.xml @@ -11,13 +11,6 @@ - -
    -
  • 12.30.2001 - revised for poi 1.0-final - minor revisions
  • -
  • 01.03.2001 - revised for poi 1.1-devel
  • -
-
-

This release of the how-to outlines functionality for 1.5. Those looking for information on the release edition should @@ -94,94 +87,99 @@ does not close it for you.

Here is some example code (excerpted and adapted from org.apache.poi.hssf.dev.HSSF test class):

- // create a new file - FileOutputStream out = new FileOutputStream("/home/me/myfile.xls"); + cs3.setBorderBottom(cs3.BORDER_THICK); //create 50 cells - for (short cellnum = (short)0; cellnum < 50; cellnum++) { + for (short cellnum = (short) 0; cellnum < 50; cellnum++) + { //create a blank type cell (no value) - c = r.createCell(cellnum,HSSFCell.CELL_TYPE_BLANK); + c = r.createCell(cellnum); // set it to the thick black border style c.setCellStyle(cs3); } @@ -215,7 +214,7 @@ org.apache.poi.hssf.dev.HSSF test class):

// demonstrate adding/naming and deleting a sheet // create a sheet, set its title then delete it s = wb.createSheet(); - wb.setSheetName(1,"DeletedSheet"); + wb.setSheetName(1, "DeletedSheet"); wb.removeSheetAt(1); //end deleted sheet @@ -223,7 +222,7 @@ org.apache.poi.hssf.dev.HSSF test class):

// close our file (don't blow out our file handles wb.write(out); out.close(); - + ]]> @@ -281,119 +280,96 @@ registered to listen for until the file has been completely read.

A code excerpt from org.apache.poi.hssf.dev.EFHSSF (which is in CVS or the source distribution) is reprinted below with excessive comments:

- -//this non-public class implements the required interface -// we construct it with a copy of its container class...this is cheap but effective -class EFHSSFListener implements HSSFListener { - EFHSSF efhssf; - public EFHSSFListener(EFHSSF efhssf) { - this.efhssf = efhssf; - } - - // we just use this as an adapter so we pass the record to the method in the container class - public void processRecord(Record record) { - efhssf.recordHandler(record); + +} +]]> @@ -427,13 +403,15 @@ export CLASSPATH=$CLASSPATH:$HSSFDIR/hssf.jar:$HSSFDIR/poi-poifs.jar:$HSSFDIR/po
  • type: java org.apache.poi.hssf.dev.HSSF ~/myxls.xls write
  • +

    This should generate a test sheet in your home directory called "myxls.xls".

    • Type: - java org.apache.poi.hssf.dev.HSSF ~/input.xls output.xls + java org.apache.poi.hssf.dev.HSSF ~/input.xls output.xls +

      This is the read/write/modify test. It reads in the spreadsheet, modifies a cell, and writes it back out. Failing this test is not necessarily a bad thing. If HSSF tries to modify a non-existant sheet then this will -most likely fail. No big deal.

    • +most likely fail. No big deal.

    @@ -510,7 +488,7 @@ intertwined. To use that just pass a file with a second argument matching "on" exactly.

    In the next release cycle we'll also have something called a FormulaViewer. The class is already there, but its not very useful -yet. When it does something, I'll document it.

    +yet. When it does something, we'll document it.

    -- 2.39.5