This is a discussion on export java program result into excel within the Java Server Pages (JSP) forums, part of the Web Development category; Hi what all results i got in java program that should be export into excel after pressing button.how to ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| there are two commonly used API available. 1. Java Excel API 2. Jakarta POI Java Excel API - A Java API to read, write and modify Excel spreadsheets.Using these APIs you can convert an excel file to a tab delimited text file. JExcelApi will not be use when these output generated was chart, graph or macro information. This information is however preserved when spreadsheets are copied When adding images to a sheet, only PNG image formats are supported For more details you can look at A Java API to read, write and modify Excel spreadsheets here is the following synapsys for sending the output to the excel Code: HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("FileName");
// Create a row and put some cells in it. Rows are 0 based.
int i=1;
i++;
HSSFRow row = sheet.createRow((short)i);
row.createCell((short)0).setCellValue("");
row.createCell((short)1).setCellValue("Headings");
i++;
row=sheet.createRow((short)i);
row.createCell((short)0).setCellValue("");
i++;
row=sheet.createRow((short)i);
row.createCell((short)0).setCellValue("");
row.createCell((short)1).setCellValue("Column Name1");
row.createCell((short)2).setCellValue("Column Name2");
.
.// all the row and column like above
.
// Write the output to a file
String savepath="";
ServletContext sc = getServletConfig().getServletContext();
//Code for creating a folder
String path=getServletContext().getRealPath("/");
File f1 = new File(path + "/Excel Export");
if(!f1.exists())
{
f1.mkdir();
}
savepath = sc.getRealPath("/") "Excel Export/""ShareholdingReport.xls";
FileOutputStream fileOut = new FileOutputStream(savepath);
wb.write(fileOut);
fileOut.close();
fileOut=null;
sheet=null;
wb=null;
//End Excel Export
__________________ cheers Aman |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Export table values into excel | oxygen | C# Programming | 2 | 03-18-2008 02:13 AM |
| Export to Excel option is not working in Crystal Report with service pack 2 | tsureshk | ASP and ASP.NET Programming | 1 | 10-06-2007 03:57 AM |
| convert Excel file to CSV(or text) file using java | mobilegeek | Java Programming | 2 | 09-06-2007 06:42 AM |
| How to execute an external program from java? | kingmaker | Java Programming | 1 | 07-30-2007 12:52 AM |
| How could Java classes direct program messages to the system console? | Sabari | Java Programming | 1 | 07-17-2007 05:13 AM |