Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export data into an Excel sheet with ASP 1

Status
Not open for further replies.

Ayac

Programmer
Nov 10, 2000
141
0
0
HU
Hi All!

I created a report generator in ASP what collects data from various Access databases of our intranet and display them as an html file in the users' browser. I would like to create an ASP program what puts this data into an Excel sheet (by clicking on a button of the page) and save it into the user's folder on the web server.
Can you please give me some guidelines where to start? I thought I might need a database activeX object compontent to do that, but I am not sure how to start this project...

Thanks!
 
All you have to do to export it to excel is add the following to the page: (have the button click set a variable called excel to "true")

Code:
if excel then
	response.ContentType="application/vnd.ms-excel" 
end if

Assuming they have the IE excel-viewer plugin, it will display as an xls file in the browser. At that point, the user can save it off as an xls file, or would imagine you could use FSO to simultaneously write it to the server. I don't know if I'd do it that way though, they could reload and write numerous files to the server (potentially a bunch of dupes...)

Hope this gets ya started!

-Scott
 
Cool! Thanks Scott! It helped me a lot!
 
Hi,
This is a query to both of you.
I have used this and it seems to work in some cases but not for others.
In some clients the excel just opens up while for others there is a prompt to either open or save. in some other cases, there is an error message that the file is not found, bla, bla.
In some cases the excel file does not open up at all .
Can you please clarify, if this solution is good for concurrent use. the same report asp is being used by multiple users simultaneously and all of them are trying to export the report.
can you please suggest how to make this work uniformly for all concurrent users and if there is any specific settings required for IE/Excel etc ? Thanks
akgd99
 
I have the same problem as an issue too. I use this code on our intranet site and we do not want to freak out our users letting them face with these popup weirdos. I just told them to save it. Frankly, I can not tell why it is not consistently handle that, but I will let you know if I can figure it out.
 
Yikes, our company is a Microsoft only shop, so I haven't seen any failures on my end. I know the previous versions of the current IE (4 and 5) sometimes had the Excel viewer built in and sometimes didn't. Also all of our machines have office installed, so windows is probably picking up the slack.

I'll poke around some and see. There may be a way to check for the plug-in or Excel installation before-hand, but probably not without using a using/writing a seperate plugin in and of itself.
 
Here's a way to check via the client before the page is opened.... (modified from:
Code:
<script language=&quot;JavaScript&quot;>
  function startExcel(strFile)
  {
    var myApp = new ActiveXObject(&quot;Excel.Application&quot;);
    if (myApp != null)
    {
      ... redirect to page that opens the ecxel doc web-page...
    }
  }
</script>

then call it with a link...

Code:
<a href=&quot;javascript:startExcel('[URL unfurl="true"]http://yoursite/test.xls')&quot;>Test.xls</a>.[/URL]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top