Link to home
Start Free TrialLog in
Avatar of AbhijitCPatil
AbhijitCPatil

asked on

How to export data to an excel sheet ?

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
Avatar of Thandava Vallepalli
Thandava Vallepalli
Flag of United States of America image

ASKER CERTIFIED SOLUTION
Avatar of matthew_york
matthew_york

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AbhijitCPatil
AbhijitCPatil

ASKER

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

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
Convert your code from JSP to ASP is very easy.... Almost most of the code will work as it is...

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