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=javasc ript>
function exportToExcel()
{
var oExcel = new ActiveXObject(" Excel.Applicati on");
var oBook = oExcel.Workbook s.Add;
var oSheet = oBook.Worksheet s(1);
for (var y=0;y<detailsTa ble.rows.length ;y++)
// detailsTable is the table where the content to be exported is
{
for (var x=0;x<detailsTa ble.rows(y).cel ls.length;x++)
{
oSheet.Cells(y+ 1,x+1) =
detailsTable.ro ws(y).cells(x). innerText;
}
}
oExcel.Visible = true;
oExcel.UserCont rol = true;
}
</script>
<button onclick="export ToExcel();">Exp ort to Excel File</button>
<table name="detailsTa ble">
<tr>
<td> hello
</td>
</tr>
</table>
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=javasc ript>
function exportToExcel()
{
var oExcel = new ActiveXObject(" Excel.Applicati on");
var oBook = oExcel.Workbook s.Add;
var oSheet = oBook.Worksheet s(1);
for (var y=0;y<detailsTa ble.rows.length ;y++)
// detailsTable is the table where the content to be exported is
{
for (var x=0;x<detailsTa ble.rows(y).cel ls.length;x++)
{
oSheet.Cells(y+ 1,x+1) =
detailsTable.ro ws(y).cells(x). innerText;
}
}
oExcel.Visible = true;
oExcel.UserCont rol = true;
}
</script>
<button onclick="export ToExcel();">Exp ort to Excel File</button>
<table name="detailsTa ble">
<tr>
<td> hello
</td>
</tr>
</table>
Comment