Solved

Export to excel problem

Posted on 2007-03-24
10
217 Views
Last Modified: 2012-06-27
Hi all,

I have script, which is used to export the table information to the excel file.
The code is working fine in client machine (I am using Windows XP & IE 6.0). If I test the same html page in other hosting server, its not downloading(not open the excel file with data).
What's the issue in that?

My code is given below:
<html>
<head>
<title>Testing</title>
</head>
<body>
<script language="vbscript">
Sub exporttoexcel
      Dim sHTML
        Dim oExcel
        Dim oBook
      sHTML = document.all.item("inner_table").outerhtml
        Set oExcel = CreateObject("Excel.Application")
      Set oBook = oExcel.Workbooks.Add
      oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
      oBook.HTMLProject.RefreshDocument
      oExcel.Visible = true
      oExcel.UserControl = true
End Sub
</script>
<table  border = 0 cell padding = 0>
<tr>
<td><font size = -1><a href='javascript:exporttoexcel()'>Export To Excel</a></td>
</tr>
</table>

<table id ="inner_table">
<tr><td> Hello</td></tr>
</table>
</body>
</html>
0
Comment
Question by:r_kar
  • 4
  • 4
10 Comments
 
LVL 4

Expert Comment

by:MacroLand
ID: 18788058
vbscript is a microsoft technology so as I know only microsoft OS supports
0
 

Author Comment

by:r_kar
ID: 18788681
MacroLand,

If I open this page using my IE explorer, it should work... right?
Its not working if I use IE browser in my XP machine.

Anyone can tell me what's happening at that end?

Thanks

0
 
LVL 4

Expert Comment

by:MacroLand
ID: 18788737
I use your code with IE on my xp machine and it works fine. However with FireFox it does not work.

The reason I guess is your script uses document.all which is Microsoft supported instead of document.getElementById which is Mozilla supported.
0
 

Author Comment

by:r_kar
ID: 18790698
MacroLand,
ok.
My problem is if I use same script in some other server (like geocities), it will not work properly.
But If I copy the code using "View Source" and tested, its working.
So what's happening in both case? No idea.... I am using same browser for both testing....

Thanks
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Accepted Solution

by:
MacroLand earned 125 total points
ID: 18791247
>>My problem is if I use same script in some other server (like geocities), it will not work properly.

I think the reason is with security attributes of your browser. If you run the file from your computer your browser considers it to be safe so it lets MS Excel to run. However if you try to run it from external resources like Goecities it is deemed as ActiveX control so your security settings does not let it run.

Regards,
0
 

Author Comment

by:r_kar
ID: 18791692
MacroLand,
Thanks for your reply.
Is there anyway to resolve this issue?
Or do you have any sample script to download the table information as excel file?
Regards
0
 
LVL 4

Expert Comment

by:MacroLand
ID: 18791901
>>Is there anyway to resolve this issue?

I think you can set your security setting to download ActiveX controls but this is totally up to you. You will be more susceptible to intrusions by this way.

Unfortunately I have no source code for this. I right click the mouse and choose Export to Excel function provided by IE which works fine for me. Sorry.

Regards,

0
 

Author Comment

by:r_kar
ID: 18825452
Hi all,

I think its difficult to get a solution for my problem. For the time being,  I will do it in server side.
I am going to Delete/Cancel this question with all your permission.

Regards
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now