求给力!

qixiaoxian1963 2011-10-11 11:35:23
各位大侠们 如何利用 js 将一个完整的html页面导入到word.页面中有图片 并且不只一个表格。求高手帮助;
像下面这样的代码没用function AllAreaWord()
{
var oWD = new ActiveXObject("Word.Application");
var oDC = oWD.Documents.Add("",0,1);
var oRange =oDC.Range(0,1);
var sel = document.body.createTextRange();
sel.moveToElementText(PrintA);
sel.select();
sel.execCommand("Copy");
oRange.Paste();
oWD.Application.Visible = true;
//window.close();
}
...全文
129 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
狗阳 2011-10-12
  • 打赏
  • 举报
回复
利用POI组件
扯出一片天 2011-10-11
  • 打赏
  • 举报
回复
//找别人的,试试吧
直接用word打开,然后存成.doc文件就可以了。

protected void ConvertToHtml(string SrcFilePath,string TargetFilePath)
{
Word.Application app=new Word.Application();
app.Visible=false;
Object o=Missing.Value;
object docFile=SrcFilePath;
_Document doc=app.Documents.Open(ref docFile,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o);
object fileName=TargetFilePath;
object format=Word.WdSaveFormat.wdFormatDocument; //word format
doc.SaveAs(ref fileName,ref format,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o);
object t=true;
app.Quit(ref t,ref o,ref o);
}
晨晨 2011-10-11
  • 打赏
  • 举报
回复
这种与WORD的接口操作,现在很多浏览器都禁掉的,最可靠的就是copy then paste
一個程序員 2011-10-11
  • 打赏
  • 举报
回复
var save = function(content, name){
var f = document.createElement('iframe');
f.style.display = 'none';
document.appendChild(f);
window[window.length - 1].document.write(content);
window[window.length - 1].document.execCommand('saveas', true, name);
document.removeChild(f);
};

save('<html>' + document.documentElement.innerHTML + '</html>', document.title + '.doc');
luyun2011 2011-10-11
  • 打赏
  • 举报
回复
用js?!有难度
用POI包可以编码操作word表格
qixiaoxian1963 2011-10-11
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 w329045069 的回复:]
//找别人的,试试吧
直接用word打开,然后存成.doc文件就可以了。

protected void ConvertToHtml(string SrcFilePath,string TargetFilePath)
{
Word.Application app=new Word.Application();
app.Visible=false;
Object ……
[/Quote]
要用js........

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧