ASF Bugzilla – Attachment 10925 Details for
Bug 27497
Charts not working
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
java example
TestExcel.java (text/plain), 2.62 KB, created by
Daniel Shaw
on 2004-03-23 17:04:50 UTC
(
hide
)
Description:
java example
Filename:
MIME Type:
Creator:
Daniel Shaw
Created:
2004-03-23 17:04:50 UTC
Size:
2.62 KB
patch
obsolete
>package com.cnetnetworks.avenue.reports.servlet; > >import com.cnetnetworks.avenue.model2servletframe.ServletM2; >import com.cnetnetworks.avenue.model2servletframe.ServletRouter; > >import javax.servlet.http.HttpServlet; >import javax.servlet.http.HttpServletRequest; >import javax.servlet.http.HttpServletResponse; >import javax.servlet.ServletException; >import java.io.IOException; >import java.io.FileInputStream; >import java.io.OutputStream; >import java.io.FileNotFoundException; > >import org.apache.poi.poifs.filesystem.POIFSFileSystem; >import org.apache.poi.poifs.filesystem.DocumentOutputStream; >import org.apache.poi.hssf.usermodel.HSSFWorkbook; >import org.apache.poi.hssf.usermodel.HSSFSheet; >import org.apache.poi.hssf.usermodel.HSSFRow; >import org.apache.poi.hssf.usermodel.HSSFCell; > >/** > * Class > * > * @author > * @version 1.1 > */ >public class TestExcel implements ServletM2 { > public ServletRouter doService(HttpServlet servlet, HttpServletRequest request, HttpServletResponse response) > throws IOException, ServletException { > > > POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(servlet.getServletContext().getRealPath(request.getParameter("xls")))); > // create a workbook out of the input stream > HSSFWorkbook wb = new HSSFWorkbook(fs,true); > > // get a reference to the worksheet > HSSFSheet sheet = wb.getSheetAt(0); > > HSSFRow x = sheet.getRow(22); > HSSFCell H23 = x.getCell((short)7); > x = sheet.getRow(23); > HSSFCell H24 = x.getCell((short) 7); > x = sheet.getRow(24); > HSSFCell H25 = x.getCell((short) 7); >// if(H23 == null){ >// H23 = x.createCell((short)8); >// } > H23.setCellValue(1234567); >// fs. > H24.setCellValue(12345); > H25.setCellValue(123); > > try { > // SET THE MIME TYPE > response.setContentType("application/vnd.ms-excel"); > response.setHeader("Content-disposition","attachment; filename=unknown.xls"); > > // set content dispostion to attachment in > // case the open/save dialog needs to appear > OutputStream out = response.getOutputStream(); > > > wb.insertChartRecord(); >// fs.write(out); >// fs.writeFilesystem(out); > out.flush(); > out.close(); > } catch (FileNotFoundException fne) { > System.out.println("File not found..."); > } catch (IOException ioe) { > System.out.println("IOException..." + > ioe.toString()); > } > > return null; > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 27497
: 10925 |
10926
|
10927