Hello guys, i intend to implement the following in my
JSP.
1.Populate the screen after running a query with
say, three fields -- X, Y , Z or more
2.Sum the three columns and display at bottom
3.Provide a link on screen, when user clicks on this link i want to download the results on screen as a CSV file
4.Then open CSV in EXCEL as a graph(e.g. pie,bar chart etc), depending the most suitable chart for
Screen results.
OR
Display an excel spreadsheet directly on browser,the user can then use spreadsheet to create chart on browser.
Using Jakarta POI / HSSF , i was able to write the excel file to my hard drive i.e. C:\oc4j\j2ee\home\abc.xsl
NOTE : I am using Oracle Container for
J2EE (OC4J)
But, i think the right implementation will be displaying the Excel on Screen so the user can use the excel chart wizard to produce the chart on the screen(browser). Is this possible?
Because if say, a thousand users are using the application , how do they access their individual excel spreadsheet on the server without file mismatch /issues.
Please, your ideas/codes will be appreciated.
This is what i am doing in my TestJSP.jsp at the moment :
<%@page contentType="application/vnd.ms-excel" %>
<%@page import="org.apache.poi.hssf.usermodel.*,java.io.*" %>
<html>
<body>
<%
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 to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
%>
</form>
</body>
</html>