I have a JSP that creates a CSV file, which works.  When I convert the JSP page
to use HSSF instead it produces no output.  The JSP just produces a blank page.
 With the CSV output the blank JSP popups up and is replaced by the Dialog to
open or save the .csv file.

My JSP is below.

And yes, I have verified that the two header and records Lists contain data.

Thanks.

Dean



<%@ page language="java" %>
<%@ page
import="java.util.*,java.io.OutputStream,org.apache.poi.hssf.usermodel.*" %>
<%
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment; filename=browselist.xls");

List headers =(List)request.getAttribute("headers");
List records =(List)request.getAttribute("records");

HSSFWorkbook wb =  new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();

HSSFFont headerFont = wb.createFont();
headerFont.setFontName(HSSFFont.FONT_ARIAL);
headerFont.setFontHeightInPoints((short) 10);
headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);


HSSFCellStyle HeaderStyle = wb.createCellStyle();
HeaderStyle.setFont(headerFont);

int rowNum = 0;

if (headers != null) {
        
        HSSFRow headerRow = sheet.createRow(rowNum++);
        Object[] arr = headers.toArray();
        
        for (int i=1; i<arr.length; i++) {
                
                String s = (String)arr[i];
                HSSFCell cell = headerRow.createCell((short)i);
                cell.setCellValue(s);
        }
}

if (records != null) {
        
        Object[] arr = records.toArray();
        
        for (int i=0; i<arr.length; i++) {

                String record = (String)arr[i];
                HSSFRow recordRow = sheet.createRow(rowNum++);
                
                StringTokenizer st = new StringTokenizer(record,"|");
                boolean skip = true;
                short cellNum = 0;
                
                while (st.hasMoreTokens()) {
                        
                        String tok=st.nextToken();   
                        if (skip) {
                                skip = false;
                                continue;
                        }
        
                        if(tok.equals("&nbsp;"))
                                tok="";
                        
                        HSSFCell cell = recordRow.createCell(cellNum++);
                        cell.setCellValue(tok);
                }
        }
}

OutputStream sos = response.getOutputStream();
wb.write(sos);
sos.close();

%>



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

Reply via email to