Neither - but if I take the "package" off then I get even more errors. All I want to do is to juts be able to create an Excel spreadsheet through a servlet - I have been able to do it with a JSP page but need to be able to connect to an Oracle database and pull records from there and them insert them into the XLS file. I have the db connection part working fine and I have iText working fine to create the PDF part of the application but for some reason I can not get HSSF to cooperate :(

R S wrote:

Are you sure you want to package your java file (WriteExcel) in the
"org.apache.poi.hssf.usermodel" package? Is your code in the
"org/apache/poi/hssf/usermodel" directory?

I hate to come off as a jerk, but it would be in your best interests
to review java packaging.

RS



On 6/10/05, James Chaney <[EMAIL PROTECTED]> wrote:
Question on setting up POI to use HSSF - I have downloaded
poi-2.5.1-final-20040804 and added it to my ClassPath variable. I then
create a java file with the following:

package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
..........

And when I try to compile it I get the following errors:
cannot resolve symbol
class HSSFWorbook
package usermodel
import org.apache.poi.poifs.filesystem.HSSFWorbook; (I get the same
error for all the imports org.apache.poi.hssf.usermodel.* - just listed
the one)

If I remove the package and import statements the rest of my java code
compiiles just fine. Can you please tell me what I may be doing wrong? I
have explained the top part in short in recommendation from the jakarta
site - here is my actual code:

package org.apache.poi.hssf.usermodel;

import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

public class WriteExcel
{
private static String filename = "C:\\temp\\sales.xls";
public static void main(String[] args)
{
    try
    {
              System.out.println(
            "Demonstration of programmatic manipulation of " +
            "Microsoft Excel Spreadsheet via the Apache POI API.");
                  // open the Excel Spreadsheet
        POIFSFileSystem fs =
            new POIFSFileSystem(new FileInputStream(filename));
        HSSFWorkbook hssfworkbook = new HSSFWorkbook(fs);
                   // grab the first sheet
        HSSFSheet sheet = hssfworkbook.getSheetAt(0);
          // grab the appropriate cell we want to manipulate
        // cell B2 maps to Row 1, Column 1
        HSSFRow row = sheet.getRow(1);
        HSSFCell cell = row.getCell((short)1);
                  // if the cell we want is not created, create
it                  if (cell == null)
            cell = row.createCell((short)1);
          // set the cell type.  In this case, our cell is numeric
        cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
          // set the cell's value
        cell.setCellValue(89000.00);
              // Write the output to a file
        FileOutputStream fileOut = new FileOutputStream(filename);
        hssfworkbook.write(fileOut);
          // Close the file
        fileOut.close();
             }
    catch(Exception e)
    {              e.printStackTrace();
    }
          }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Reply via email to