从html页面打印表格 [英] Print a table from an html page

查看:451
本文介绍了从html页面打印表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html页面,需要从该页面将表发送到打印机.我现在正在使用window.print ..但这会打印整个页面...而我只需要打印表格.有什么想法吗?

I have a html page, from which a table needs to be sent to a printer. I am using window.print right now.. but that prints the whole page... while I need to print just the table. Any ideas?

推荐答案

  1. 您可以使用打印媒体类型(这是一些提示,如何使用样式表打印html页面).

  1. You can use media types print (here is tips, how print html page using stylesheets).

您可以通过弹出窗口认识到-在此窗口中仅显示表格并将其发送给打印机.

You can realize that through popup window - in this window show only table and send it to printer.

简单的例子

<script>
    function printDiv() {
        var divToPrint = document.getElementById('areaToPrint');
        newWin = window.open("");
        newWin.document.write(divToPrint.outerHTML);
        newWin.print();
        newWin.close();
   }
</script>

这篇关于从html页面打印表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆