Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Import from and export to Excel

 
Adithya Rayaprolu
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
We have a table in our page. When user right clicks on the table, a context menu is shown and in that we have two menu items: Export to Excel and Import from Excel. We need the table to be imported from and exported to Excel. Everything should be done at client side. How to do this? I have no idea how the .xls file format would be. How to launch the Excel window when he selects 'Export to Excel'?. When he selects 'Import from Excel', we need to show a browse folder dialog and then he selects the .xls file. How to convert this into the html table?
Thanks a lot in advance.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it has to be done sever side since javascript has no control over redaing and writing to files. ASP can read excel files and write to them. There may be some active X thing.
<input type="file"> will allow you to browse.
The only hting i think you might be able to do is do it with frames and have the top frame be the info and the bottom frame being the excel sheet.
 
Adithya Rayaprolu
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi eric,
Thanks for the info. For testing purpose, we created an html table in a text file and named it as test.xls, I wrote a function which has only one line
window.open('test.xls','','resizable=yes,height=475,width=800');
When I call this function from the context menu item, its perfectly showing the excel speadsheet.
I have one more question. In Javascript, we cannot do file reading or writing. So, we have to send the table data to server and let server convert the data into an xls file, and when we receive it, we can show it in excel. How do we send the whole table data to the server?
And in Import from Excel, we will get the file name from the dialog. How do we send the file contents to server, so it can send us the xls file data to a simple html table?
Thanks.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
look here: http://www.asp101.com/samples/xl.asp
see if this helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic