永发信息网

网页表格导出到word

答案:3  悬赏:20  手机版
解决时间 2021-01-24 17:35
怎么把网页中某个表格中的一个单元格内容导出到一个一个指定的word文档中,跪求详细代码
最佳答案
function jscomExportTableToWord(tableName)<br> {<br>  if(document.all(tableName).rows.length==0)<br>  {<br>   alert("没有内容可导!");<br>   return;<br>  }<br><br>  var oWord;<br>  try{<br>   oWord = new ActiveXObject("Word.Application"); // Get a new workbook.<br>  }catch(e)<br>  {<br>   alert("无法调用Office对象,请确保您的机器已安装了Office并已将本系统的站点名加入到IE的信任站点列表中!");<br>   return;<br>  }<br>  var oDocument = oWord.Documents.Add();<br>  var oDocument = oWord.ActiveDocument; <br>  //oDocument.Paragraphs.Add();<br>  oDocument.Paragraphs.Last.Alignment = 1;<br>  oDocument.Paragraphs.Last.Range.Bold = true;<br>  oDocument.Paragraphs.Last.Range.Font.Size = 16;<br>  oDocument.Paragraphs.Last.Range.Font.name = "宋体";<br>  oDocument.Paragraphs.Last.Range.InsertAfter(document.all("lblTitle").innerText);<br><br>  oDocument.Paragraphs.Add();<br>  oDocument.Paragraphs.Last.Alignment = 2;<br>  oDocument.Paragraphs.Last.Range.Bold = false;<br>  oDocument.Paragraphs.Last.Range.Font.Size = 12;<br>  oDocument.Paragraphs.Last.Range.Font.name = "宋体";<br>  oDocument.Paragraphs.Last.Range.InsertAfter(document.all("lblSubTitle").innerText);<br><br>  var table = document.all(tableName);<br>  var nRows = table.rows.length; <br>  var nCols = table.rows(0).cells.length;<br>  for (i=0;i<nRows;i++)<br>  {<br>   nCol=0;<br>   nCols=table.rows(i).cells.length;<br>   for (j=0;j<nCols;j++) <br>   { <br>    if(table.rows(i).cells(j))<br>    {<br>    oDocument.Paragraphs.Add();<br>    oDocument.Paragraphs.Last.Alignment = 0;<br>    oDocument.Paragraphs.Last.Range.Bold =false;<br>    if(j==0)<br>    oDocument.Paragraphs.Last.Range.Font.Size = 14;<br>    else<br>    oDocument.Paragraphs.Last.Range.Font.Size = 10;<br>    oDocument.Paragraphs.Last.Range.Font.name = "宋体";<br>    oDocument.Paragraphs.Last.Range.InsertAfter(table.rows(i).cells(j).innerText);<br>    }<br>    nCol=nCol+1;<br>   } <br>  }<br>  oWord.Visible = true;<br> }
全部回答
jsp输出word 在页面直接打开word。 在action中写 response.reset(); response.setcontenttype("application/msword;charset=gbk"); response.setheader("content-disposition", "inline;filename=temp.doc"); response.getoutputstream().write(document.getcontent()); response.getoutputstream().flush(); response.getoutputstream().close(); return null; 在页面时下载word。 在action中写 response.reset(); response.setcontenttype("application/x-download;charset=gbk"); response.setheader("content-disposition", "attachment;filename=temp.doc"); response.getoutputstream().write(document.getcontent()); response.getoutputstream().flush(); response.getoutputstream().close(); return null;
这个不用代码页可以实现的,直接选择并且导出为doc文档就可以了。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
图10为太阳直射点移动轨迹,图11为地球公转示
根子供电服务所地址好找么,我有些事要过去
亿家保洁(风华路2-201号附近亿家保洁)怎么去
药品注册检验,包括A.样品检验和临时抽检B.样
拜耳的one a day 维生素 怎么样
中国南方电网(宝圩供电所供电营业厅)地址有知
海是怎么形成的
赤道没有穿过的大洋是CA. 太平洋B. 大西洋C.
经期能吃蕨根粉吗
航模怎么做的
公馆供电所(公馆营业厅)地址在什么地方,我要
太阳大气结构从里向外是DA. 光球-日冕-色球
古丁供电所(古丁营业厅)地址在什么地方,我要
打完疫苗了 伤口有点疼
女,28岁,宫内孕39周,第一胎,见红并阵发性
推荐资讯
96孔pcr板裙边和半裙边什么意思
造纸厂计划每天生产13.5吨,实际每天比原计划
玩游戏掉帧和cpu温度有关吗
女朋友父母闹离婚,我该怎么安慰她?
根据《刑事诉讼法》的相关规定,下列选项中属
为什么我看到长得丑又猥琐的老男人就恶心反胃
庆国启智幼儿园地址有知道的么?有点事想过去
求一篇以听蝉夜语,话梦几许为题的作文
河南省县级公路局今后会怎么改革事业编制会有
甲公司是从事商品批发业务的商业企业,2014年
邮政通信服务水平的管理内容包括服务网点和(
梨花酒哪里可以买到?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?