B
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>
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>