App为我定义的层ID,你替换为表格ID,我是打印,你调用一下SaveAs函数.
function PrintFile()
{
var strResult=window.confirm("确认用Word打印吗?");
if(strResult)
{
try
{
App.focus();
document.execCommand("SelectAll");
document.execCommand("Copy");
App.focus();
var WordApp=new ActiveXObject("Word.Application");
WordApp.Application.Visible=true;
var Doc=WordApp.Documents.Add();
Doc.Activate();
Doc.Content.Paste();
Doc.PrintPreview();
WordApp.DisplayAlerts=false;
Doc.Close();
WordApp.DisplayAlerts=true;
WordApp.Quit();
}
catch(e){}
}
else
{
var hwnd=window.open("");
hwnd.document.write(App.innerHTML);
}
return false;
}
function PrintFile()
{
var strResult=window.confirm("确认用Word打印吗?");
if(strResult)
{
try
{
App.focus();
document.execCommand("SelectAll");
document.execCommand("Copy");
App.focus();
var WordApp=new ActiveXObject("Word.Application");
WordApp.Application.Visible=true;
var Doc=WordApp.Documents.Add();
Doc.Activate();
Doc.Content.Paste();
Doc.PrintPreview();
WordApp.DisplayAlerts=false;
Doc.Close();
WordApp.DisplayAlerts=true;
WordApp.Quit();
}
catch(e){}
}
else
{
var hwnd=window.open("");
hwnd.document.write(App.innerHTML);
}
return false;
}
解决方案 »
- alert问题
- jqueryUI Grid 与JQGird哪个用着更好.
- 谁知道 BeGone 这款游戏是怎么开发的?
- jquery1.4.4下引入jquery1.4.2写的方法 报错!!
- 有javascript高手帮忙吗,高报酬
- 问个比较基础的问题
- 编码转换问题
- 有关“联动下拉菜单”!!!!应该不是很简单
- blur()是啥东西?代码中有句onclick=javascript:this.blur(),不清楚是什么意思!
- 日期转换难题。
- 我在一页面A.htm 点击一个链接 打开新的页面B.htm,B.htm在A.htm前面 只有B.htm关了 A.htm页面才被激活 怎么实现
- 关于在客户端调用word打开网页的javascript的问题
怎样做不用设置安全级别就能将网页保存为word格式的文档呢?
谢谢了,,