Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

HSSF errors in Java code

807597Jun 8 2005 — edited Jul 4 2005
I have downloaded the POI from jakarata and have it installed and my classpath pointing to the poi-2.5.1-final-20040804.jar file. I then took the example file from the POI website to create and xls file:

package org.apache.poi.hssf.usermodel;

import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFCreate;

public class HSSFCreate extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
}

public void destroy() {
}

/** Processes requests for both HTTP GET and POST methods.
* @param request servlet request
* @param response servlet response
*/

protected void processRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

response.setContentType("application/vnd.ms-excel");
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)0);

// Create a cell and put a value in it.
HSSFCell cell = row.createCell((short)0);

cell.setCellValue(1);

// Or do it on one line.
row.createCell((short)1).setCellValue(1.2);
row.createCell((short)2).setCellValue("This is a string");
row.createCell((short)3).setCellValue(true);
// Write the output
OutputStream out = response.getOutputStream();
wb.write(out);
out.close();
}

/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/

protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}

/** Handles the HTTP POST method.
* @param request servlet request
* @param response servlet response
*/

protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}

/** Returns a short description of the servlet.
*/

public String getServletInfo() {
return "Example to create a workbook in a servlet using HSSF";
}
}

And no matter what I do I still get the following errors:

HSSFCreate.java:27: cannot resolve symbol
symbol : class HSSFWorkbook
location: class org.apache.poi.hssf.usermodel.HSSFCreate
HSSFWorkbook wb = new HSSFWorkbook();
^
HSSFCreate.java:27: cannot resolve symbol
symbol : class HSSFWorkbook
location: class org.apache.poi.hssf.usermodel.HSSFCreate
HSSFWorkbook wb = new HSSFWorkbook();
^
HSSFCreate.java:28: cannot resolve symbol
symbol : class HSSFSheet
location: class org.apache.poi.hssf.usermodel.HSSFCreate
HSSFSheet sheet = wb.createSheet("new sheet");
^
HSSFCreate.java:31: cannot resolve symbol
symbol : class HSSFRow
location: class org.apache.poi.hssf.usermodel.HSSFCreate
HSSFRow row = sheet.createRow((short)0);
^
HSSFCreate.java:34: cannot resolve symbol
symbol : class HSSFCell
location: class org.apache.poi.hssf.usermodel.HSSFCreate
HSSFCell cell = row.createCell((short)0);
^
5 errors

Any ideas on how I can get rid of these errors?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 1 2005
Added on Jun 8 2005
4 comments
1,165 views