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/

Reply via email to