Ale*_*lex 6 .net html css printing c#-2.0
我已经创建了一个基于HTML的报告,它可以是C#中的可变长度和段数(这就是为什么不使用Crystal Reports),我不能使用精彩的http://www.printfriendly.com/作为报告是基于内联网的(boooo,hiss).
我已经创建了一个media = print CSS文件,用于使格式化为纸张和墨水尽可能高效,但我有一个问题.报告中有一个非常长的表,大约有50个表行,每个表都围绕高度:200px.不幸的是,由于自动分页,一些表行被切片,一部分表行在一页上,其余部分在下一页上.无论如何(希望通过CSS),将分页符选项设置为不分离表格元素(或类似元素)?
谢谢,亚历克斯
该page-break-inside: avoid
属性应该控制这一点,但看起来大多数浏览器不支持tr
或td
元素。在我的测试中,Opera 是唯一支持此属性的系统,如以下测试中所使用的:
<!DOCTYPE html>
<title>Page Break Test</title>
<style>tr, td { page-break-inside: avoid }</style>
<table border=1>
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
</table>
Run Code Online (Sandbox Code Playgroud)
如果你会使用 Opera,这可能就足够了。另一种选择是使用Prince来打印报告,因为它往往比浏览器对打印样式表功能有更好的支持(尽管我没有特别测试过此功能)。