Two spreadsheets were created, one with HSSF, the other by manually keying
the spreadsheet.
The spreadsheets look identical when opened in Excel.

When I used the BIFFVIEWER, the results for the DIMENSIONS record for HSSF
and and for
manual keying of the spreadsheet were different. HSSF - .firstrow = 0,
.lastrow = 3,
.firstcol = 0, .lastcol = 5. Manually keyed spreadsheet - .firstrow = 0,
.lastrow = 3,
.firstcol = 0, .lastcol = 6.

As noted in a prior submission to the mailing list on the topic of HSSF and
JDBC,
ResultSetMetaData.getColumnCount() does not return the correct column count
for the
spreadsheet created with HSSF. The column count is one less than that
returned from the
manually keyed sheet.

Is the defect in my coding or should I submit a bug report?

My name is Rodney Speel, but I am using this email account until I get an
email client that
encodes in plain text.

Here's the code used to create the Excel spreadsheet with HSSF.

import org.apache.poi.hssf.usermodel.*;
import java.io.*;
import java.util.*;

public class test5f
{

    public static void main (String[] parameters)
    {
        // Check the input parameters.
        if (parameters.length != 3) {
            System.out.println("");
            System.out.println("Usage:");
            System.out.println("");
            System.out.println("   test5 sheetName reportFolder columns");
            System.out.println("");
            System.out.println("");
            System.out.println("For example:");
            System.out.println("");
            System.out.println("");
            System.out.println("   test5 excelSheet " +
                                "
\\SystemName_01pdc\\CompanyFolder\\Subfolder\\ 10");
            System.out.println("");
            return;
        }

        String sheetName        = parameters[0];
        String reportFolder     = parameters[1];
        String columns          = parameters[2];
        Integer setupColumns = Integer.valueOf(columns);
        Object x = new test5f(sheetName, reportFolder, setupColumns);
    }
  public test5f(String sheetName, String reportFolder, Integer
setupColumns) {
       try {

          short rownum;
          short cellNumber;

          // declare a row object reference
          HSSFRow r = null;
          // declare a cell object reference
          HSSFCell c = null;

          HSSFWorkbook newwb = new HSSFWorkbook();
          HSSFSheet sheet = newwb.createSheet("Sheet1");
          for (rownum = (short) 0; rownum < 3; rownum++)
          {  // create a row
             r = sheet.createRow(rownum);

             // create columns
             for (short cellnum = (short) 0; cellnum <
setupColumns.shortValue(); cellnum ++)
             {
                c = r.createCell(cellnum);
                c.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                c.setCellValue(1000 * cellnum);
             }
          }
          System.out.println ("Row =" + r.getRowNum());
          System.out.println ("Cell =" + c.getCellNum());
          FileOutputStream newFileOut = new FileOutputStream(
                                         reportFolder + sheetName +
".xls");
          newwb.write(newFileOut);
          newFileOut.close();
       }

       catch (Exception e) {
           System.out.println ();
           System.out.println ("ERROR: " + e.getMessage());
           e.printStackTrace();
       }
    }

}


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to