IT Community - Software Programming, Web Development and Technical Support

export java program result into excel

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 ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Java Server Pages (JSP)

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 09-11-2007, 11:45 AM
chandana chandana is offline
D-Web Trainee
 
Join Date: Sep 2007
Posts: 1
chandana is on a distinguished road
Default export java program result into excel

Hi

what all results i got in java program that should be export into excel after pressing button.how to write java code for this
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-14-2007, 08:08 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Default Re: export java program result into excel

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 10:40 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0