日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

实现excel在线打印

發(fā)布時(shí)間:2023/12/20 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 实现excel在线打印 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

? ?這個(gè)功能和上一篇實(shí)現(xiàn)pdf內(nèi)容中前面都差不多,讓我們直接上代碼

? body內(nèi)按鈕:

<div id='exclepdf' class="buttoncss" onclick="printout()"><img src="...."><span>在線打印</span> </div>

?css樣式設(shè)計(jì):

.buttoncss{height:35px;width:100px;text-align:center;margin:10px 0px 0px 15px;border:1px solid;float:right;margin-bottom:15px; } #excelpdf:hover {cursor:pointer; } .buttoncss img{width:25px;padding-top:5px;display:inline-block; } .buttoncss span{display:inline-block;padding-left:5px;vertical-align:super; }

引入工具人js文件:

<script src="jquery-3.4.1.js"><script> <script src="jspdf.debug.js"><script> <script src="html2canvas.min.js"><script>

重點(diǎn)來(lái)咯,關(guān)于這一在線打印目前我找到四種方法可以實(shí)現(xiàn)這一功能

開(kāi)始第一個(gè):

//整個(gè)頁(yè)面直接打印 function printout(){var newWindow;//打開(kāi)一個(gè)新的窗口newWindow = window.open();//是新窗口獲得焦點(diǎn)newWindow.focus();//保存寫(xiě)入內(nèi)容var newContent = "<html> <head> <meta charset='utf-8'/><title>打印</title> </head><body>"newContent += document.getElementById("showPC").outerHTML;newContent += "</body></html>"//將html代碼寫(xiě)入新窗口中newWindow.documment.write(newContent);newWindow.print();//close layout streamnewWindow.document.close();//關(guān)閉打開(kāi)的臨時(shí)窗口newWindow.close();return false; }

第二個(gè)吖:

function printout(){if(!!window.activexobject || "activexobject" in window){remove_ie_header_and_footer();}window.print(); }; funtion remove_ie_header_and_footer();{var hkey_root,hkey_path,hkey_key;hkey_path = "hkey_current_user\\software//microsoft\\internet explorer \\pagesetup\\";try{var regwsh = new activexobject("wscript.shell");regwsh.regwrite(hkey_path + "header","");regwsh.regwrite(hkey_path + "footer","");}catch(e){} }

第三個(gè)屬于直接讓頁(yè)面打印簡(jiǎn)單方便,如不顏色,可直接用這個(gè)方法去實(shí)現(xiàn)excel打印:

funtion printout(){window.print(); }

第四個(gè),同樣也是最后一個(gè),看到這個(gè)可能就沒(méi)啦,還不在上面挑一個(gè)再走?

function printout(printout){var headhtml = "<html><head><title></title></head><body>";var foothtml = "<body/>";//獲取div中的html內(nèi)容var newhtml = document.all.item(ShowPc).innerHTML;//獲取div中的html內(nèi)容var oldhtml = $("#" + ShowPc).html();var oldhtml = document.body.innerHTML;document.body.innerHTML = headhtml + newhtml + foothtml;window.print();document.body.innerHTML = oldhtml;return false; }

總結(jié)

以上是生活随笔為你收集整理的实现excel在线打印的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。