473,320 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

javascript send to excel

bob
Hi Everyone,

I've tried looking at loads of sites but none have helped me so I hope
someone here can.
I'm bringing up a webpage with a table which i want to send to excel via a
button without re-running the webpage query to load the table again.

I've tried the code below and lots of different alternatives but no joy,
this one seems to get further than the others though, when I click the
button I get the following error "Automation server can't create object"
line 4 char 1
Excel is on the server and client pc running the page, the folder has write
access in iis aswell, any ideas or alternative coding?

Many thanks,
Rob

<script language=javascript>
function exportToExcel()
{
var oExcel = new ActiveXObject("Excel.Application");
var oBook = oExcel.Workbooks.Add;
var oSheet = oBook.Worksheets(1);
for (var y=0;y<detailsTable.rows.length;y++)
// detailsTable is the table where the content to be exported is
{
for (var x=0;x<detailsTable.rows(y).cells.length;x++)
{
oSheet.Cells(y+1,x+1) =
detailsTable.rows(y).cells(x).innerText;
}
}
oExcel.Visible = true;
oExcel.UserControl = true;
}
</script>

<button onclick="exportToExcel();">Export to Excel File</button>
<table name="detailsTable">
<tr>
<td> hello
</td>
</tr>
</table>
Jul 23 '05 #1
1 13776
VK
[presuming you have IE installed]

Change the page extension from .html to .hta

Run again, grand permission when asked and enjoy (unless there are some
coding errors in the script itself, I did not check it).

Later may take some to read about HTA (Hyper Text Application), automation,
and mostly about browser security model (msdn.microsoft.com would be a good
start).


Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dead | last post by:
Hi, Is it possible to set the output file name of a excel file from javascript? I have a code which copies the content of an html page and pastes it into excel. I want the user to save the...
0
by: Chris | last post by:
Hi, I have a service that executes a SP in sql server. This SP takes a long time to run. I now want the SP to send an email with an excel attachment of all files changed to multiple user. Should I...
13
by: Richard H | last post by:
Hi, I am building a site for a client which has an enquiry form on it. Normally I would something like PHP to send the form but the client doesn't want to pay for a server that supports PHP, so...
1
by: Sudhesh | last post by:
Hi, I found a very nice artice to convert a dataset to XML file that complies with EXCEL schema http://www.codeproject.com/dotnet/ExportToExcel.asp However, the one thing that article didn't...
2
by: renjith.nair | last post by:
Hi, i had connected excel sheet from a javascript page,but when the insertions and deletions are doing,in the browser it shows an error as: This command is unavailable because the license to use...
5
by: Dan | last post by:
Hi, Is there a way to send information via javascript by redirecting to a page that contains frames? The information that will have to be sent will be the page name of the original page before...
0
by: greg g. | last post by:
Hi, I'm developping an ASP.NET application that must fax EXCEL files. I tried by using the FAXCOMLIb libraries, using the Windows Fax Server. It works fine, except because of EXCEL: it seems...
2
atljpe
by: atljpe | last post by:
Simply looking for a code that will take data from an excel spreadsheet to inline text in a new message in outlook. Not an attachment, that I can do. I Just cannot figure out how to send data to...
13
by: Peter | last post by:
VS2008 ans ASP.NET 3.5, Office 2003 What is the best way to run Excel Template from ASP.NET web page were the Excel is only installed on the client without any ActiveX? If so can someone point...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.