asp.net页面导出excle并打开excel~~
先在页面上点击按钮后把数据导入到excel 不是保存成文件 ,而是点了按钮后启动excel并把数据输入到excel表格里面
[解决办法]
打开excel你需要使用
<html><head><script type="text/javascript">function write_to_excel(){str="";var mytable = document.getElementsByTagName("table")[0];var ExcelApp = new ActiveXObject("Excel.Application");var ExcelSheet = new ActiveXObject("Excel.Sheet");ExcelSheet.Application.Visible = true; for(var i=0; i < mytable.rows.length; i++) { for(var j=0; j < mytable.rows[i].cells.length; j++) {ExcelSheet.ActiveSheet.Cells(i+1,j+1).Value = mytable.rows[i].cells[j].innerHTML; } }}</script></script></head><body><input type="submit" value="Export to EXCEL" onclick="write_to_excel();"/><table><tr><td>First</td><td>second</td></tr><tr><td>2222</td><td>223333</td></tr></table></body></html>