Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to export data to an excel sheet ?

Posted on 2004-10-18
9
447 Views
Last Modified: 2008-02-01
I read data from database. I need to put all data to an excel sheet and display at the client side.
Let me know how can i do that. I tried changing contentType to vnd-msexcel. But this does not display the cell borders
0
Comment
Question by:AbhijitCPatil
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 12338342
0
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 12338344
0
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 12338354
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 1

Accepted Solution

by:
matthew_york earned 125 total points
ID: 12338700
In case you want to do this in java rather than using the ASP examples that itsvtk gave:

You could use the hssf part of poi in a servlet:

http://jakarta.apache.org/poi/hssf/
http://jakarta.apache.org/poi/hssf/how-to.html

Let me know if you need any further code examples.


0
 

Author Comment

by:AbhijitCPatil
ID: 12338789
HI

i am using JSP as UI so this has to done at clients side
so is there any way i can do it in javascript

any way Thanks a lot for Help

Rgds
Abhijit
0
 
LVL 1

Expert Comment

by:prabhukrishnan
ID: 12343215

When you need to set content type to something other that text/html, I think it is better to use a servlet.

In one project where we needed this functionality,we used a servlet.Set the content type to application/vnd.ms-excel.
Created a tab delimited string for the required columns and sent the string.

regards
Prabhu
0
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 12355062
Convert your code from JSP to ASP is very easy.... Almost most of the code will work as it is...

itsvtk
0
 

Author Comment

by:AbhijitCPatil
ID: 12431100
Hi  matthew_york

Now i am able to write to excel file. Thanks for Ur help.

Now there is one more problem Now i want to retrive the data.
back means now i want to read the Excel file
is there any way

Thanking you

Abhijit
0
 
LVL 1

Expert Comment

by:matthew_york
ID: 12654182
Hi Abhijit, I'd use something along the following lines:

// Open workbook
HSSFWorkbook wb = new HSSFWorkbook(new POIFSFileSystem(new FileInputStream("c:\\temp\\blank.xls")));

// Edit workbook
HSSFSheet sheet = wb.getSheet("Sheet1");
HSSFRow row = sheet.getRow(9);
HSSFCell cell = row.getCell((short) 2);

// Get Value
double value = cell.getNumericCellValue();
// or
String value = cell.getStringCellValue();

Hope this helps.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java.util.concurrent.locks in java 3 199
grep code 4 199
HTML5 vs JSP - REST based application development 4 1,200
how to exclude a file using regex 5 121
IT certifications are a concrete representation of continual learning on the part of the candidate.  Continual learning is necessary for the long term success of an IT professional, but are IT certifications the right path for you?
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question