• Post Reply Bookmark Topic Watch Topic
  • New Topic

exporting data from mysql to excel sheet  RSS feed

 
Anurag Dhiman
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello frnz!
I need to export all the mysql database data to an excel sheet. But the problem is I need to save the excel generated file into a dynamic location. I am expecting it to work like...
Whenever I click on export button it should ask for the location where you want to save the file.
Please give some idea how can I do it.







Regards,
anurag
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to clarify - do you mean:

1. You have a mysql database on/available to a web server
2. You want a client to be presented with a HTML web page to request exporting that data to an excel sheet.
3. You want the client to be able to request the exported data and save it.

If so, the process of creating the excel sheet and the selection of where to save it are two different tasks taking place on two different machines.

This kind of thing gets discussed here a lot - browse / search in this forum.

Bill
 
Paul Clapham
Sheriff
Posts: 22379
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of button is that? A web application? A Swing application? Something else? Don't forget to TellTheDetails (<-- follow that link).
 
Anurag Dhiman
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guyz!
Paul Clapham,
I have a web application and exporting the records from mysql to excel facility is provided to user. Everything is working but I need save button which when clicked open a window with browse button to select the destination for generated file.
 
Paul Clapham
Sheriff
Posts: 22379
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So would it be safe for me to guess that, for a start, you want to send the Excel file to the user as the response to some request?

(I ask because sometimes people think that the user can somehow choose a location on the server where the file should be stored. This isn't possible, if that's what you had in mind.)

Going with my guess, then what you do is to have your servlet write the Excel data to the response's output stream. There's a header you should specify to tell the browser that the data being sent is supposed to be treated as a download, but I forget what it is. And you should specify the correct MIME type for Excel files also. You should bear in mind that your application can't completely control what the browser does with such downloads; it's possible for the user to configure the browser so that downloads of a particular MIME type will always be opened with a particular application. However in normal circumstances the browser will open a dialog box prompting the user to select a location to store the download.

This all doesn't have anything to do with Excel or MySQL, it's all about how to write your servlet to do a file download. So I'll move this post to the Servlets forum.
 
Anurag Dhiman
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul!
I will try the way you are telling and get back to you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!