unclesvenno
Programmer
Hello,
I am trying to export data inserted into an HTML page to an Excel spreadsheet. If I right click on the HTML page I get an option "Export to Microsoft Excel", this works fine, however I wanted to use a button on the page to do it.
I am using the following HTML code :
and :
When I click the "Export" button the page appears to Refresh and at the bottom of the browser it reads "Done". Can anyone see what I'm doing wrong?
Thanks again,
Uncle Svenno
I am trying to export data inserted into an HTML page to an Excel spreadsheet. If I right click on the HTML page I get an option "Export to Microsoft Excel", this works fine, however I wanted to use a button on the page to do it.
I am using the following HTML code :
Code:
function cmdExport(form)
{
var xls = new ActiveXObject ("Excel.Application");
xls.visible = true;
var x1FileName = "[URL unfurl="true"]http://intranet/calculator.xls";[/URL]
var x1Book = xls.Workbooks.Open(x1FileName);
xls.ActiveSheet.Cells(4,2).value = form.numfiles.value;
xls.ActiveSheet.Cells(5,2).value = form.numpages.value;
xls.ActiveSheet.Cells(6,2).value = form.numdocs.value;
xls.ActiveSheet.Cells(7,2).value = form.numexpages.value;
xls.ActiveSheet.Cells(8,2).value = form.pagedel.value;
xls.ActiveSheet.Cells(9,2).value = form.thirdparty.value;
xls.ActiveSheet.Cells(27,3).value = form.postagecost.value;
var fname = xls.GetSaveAsFilename("Estimate.xls", "Excel Spreadsheets (*.xls), *.xls");
if (fname==""){
fname="C:\\Estimate.xls";
}
x1Book.SaveAs(fname);
x1Book.Close;
xls.visible = false;
xls.Quit();
}
and :
Code:
<input type="submit" value="Export" onClick="cmdExport(this.form)">
When I click the "Export" button the page appears to Refresh and at the bottom of the browser it reads "Done". Can anyone see what I'm doing wrong?
Thanks again,
Uncle Svenno