使用水晶报表的人经常会感慨,这么强的报表工具,连个斜线也没有,太不可理解了。
就这么个小效果,折腾坏不少人。
而VS2005里的RDLC工具,是有斜线的,但是当放到WEB应用时,模板上画得好好的,运行起来后,斜线消失了?
简单分析一下HTML代码
- HTML code
-
<DIV style="overflow:auto;HEIGHT:100%;WIDTH:100%" ID="oReportDiv" onscroll="ShowFixedHeaders()"
onresize="ShowFixedHeaders()">
<TABLE CELLSPACING="0" CELLPADDING="0">
<TR>
<TD ID="oReportCell" onpropertychange="ShowFixedHeaders()">
<DIV class="a1">
<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" COLS="12" LANG="zh-CN"
class="r10">
<TR>
<TD style="HEIGHT:10.00mm;WIDTH:25.00mm">
< SPAN>TD>
<TD style="WIDTH:5.00mm">
< SPAN>TD>
<TD style="WIDTH:7.50mm">
< SPAN>TD>
<TD style="WIDTH:2.50mm">
< SPAN>TD>
<TD style="WIDTH:5.00mm">
< SPAN>TD>
<TD style="WIDTH:37.69mm">
< SPAN>TD>
<TD style="WIDTH:9.93mm">
< SPAN>TD>
<TD style="WIDTH:4.88mm">
< SPAN>TD>
<TD style="WIDTH:2.55mm">
< SPAN>TD>
<TD style="WIDTH:12.45mm">
< SPAN>TD>
<TD style="WIDTH:22.51mm">
< SPAN>TD>
<TD style="WIDTH:24.95mm">
< SPAN>TD>
< SPAN>TR>
<TR VALIGN="top">
<TD COLSPAN="5" style="HEIGHT:2.50mm">
< SPAN>TD>
<TD ROWSPAN="3" COLSPAN="2">
<v:group coordsize="100,100" coordorigin="0,0" style="WIDTH:47.62mm;HEIGHT:19.84mm">
<v:line from="0,0" to="100,100" strokecolor="#0" strokeWeight="1pt">
<v:stroke dashstyle="solid" />
< SPAN>v:line>
< SPAN>v:group>
< SPAN>TD>
<TD ROWSPAN="3" COLSPAN="5">
< SPAN>TD>
< SPAN>TR>
<TR>
<TD COLSPAN="5" style="HEIGHT:12.50mm">
< SPAN>TD>
< SPAN>TR>
<TR>
<TD COLSPAN="5" style="HEIGHT:4.84mm">
< SPAN>TD>
< SPAN>TR>
<TR>
<TD COLSPAN="12" style="HEIGHT:5.16mm">
< SPAN>TD>
< SPAN>TR>
<TR VALIGN="top">
<TD COLSPAN="2" style="HEIGHT:10.00mm">
< SPAN>TD>
<TD COLSPAN="8">
<TABLE CELLSPACING="0" CELLPADDING="0" LANG="zh-CN">
<TR>
<TD style="WIDTH:82.54mm;word-wrap:break-word;HEIGHT:10.00mm;" class="a8">
xxxx
< SPAN>TD>
< SPAN>TR>
< SPAN>TABLE>
< SPAN>TD>
<TD COLSPAN="2">
< SPAN>TD>
< SPAN>TR>
<TR>
<TD COLSPAN="12" style="HEIGHT:5.00mm">
< SPAN>TD>
< SPAN>TR>
<TR>
<TD style="HEIGHT:12.54mm">
< SPAN>TD>
<TD COLSPAN="10" style="border-width:0px;border-top:1pt Solid Black">
< SPAN>TD>
<TD>
< SPAN>TD>
< SPAN>TR>
<TR VALIGN="top">
<TD COLSPAN="4" style="HEIGHT:9.88mm">
< SPAN>TD>
<TD ROWSPAN="2" COLSPAN="5">
<v:group coordsize="100,100" coordorigin="0,0" style="WIDTH:60.05mm;HEIGHT:17.46mm">
<v:line from="0,100" to="100,0" strokecolor="#0" strokeWeight="1pt">
<v:stroke dashstyle="solid" />
< SPAN>v:line>
< SPAN>v:group>
< SPAN>TD>
<TD ROWSPAN="2" COLSPAN="3">
< SPAN>TD>
< SPAN>TR>
<TR>
<TD COLSPAN="4" style="HEIGHT:7.58mm">
< SPAN>TD>
< SPAN>TR>
<TR>
<TD COLSPAN="12" style="HEIGHT:7.50mm">
< SPAN>TD>
< SPAN>TR>
<TR>
<TD COLSPAN="12" style="HEIGHT:30.00mm">
< SPAN>TD>
< SPAN>TR>
< SPAN>TABLE>
< SPAN>DIV>
< SPAN>TD>
<TD WIDTH="100%" HEIGHT="0">
< SPAN>TD>
< SPAN>TR>
<TR>
<TD WIDTH="0" HEIGHT="100%">
< SPAN>TD>
< SPAN>TR>
< SPAN>TABLE>
< SPAN>DIV>
我们看到线是用VML来绘制的
- XML code
-
<v:group coordsize="100,100" coordorigin="0,0" style="WIDTH:47.62mm;HEIGHT:19.84mm">
<v:line from="0,0" to="100,100" strokecolor="#0" strokeWeight="1pt">
<v:stroke dashstyle="solid" />
< SPAN>v:line>
< SPAN>v:group>
但是,页面上却少了让页面解析VML标签的声明
v\:* {behavior:url(#default#VML);}
于是解决思路就有了,主动在页面上附加上这个声明。
实际做起来就比较复杂,因为表面上RDLC页面是内嵌了一个iframe,实际上套了frame后又嵌了个iframe.
反正挺折腾人,解决方法如下:
1:新建一个x.css,放在同目录下
内容为:v\:* {behavior:url(#default#VML);}
2:在aspx的html模式下,加上如下代码即可。
- JScript code
-
<script language="javascript" type="text/javascript">
try{
var oWindow = document.getElementById('ReportFrameReportViewer1').contentWindow ;
var oHead=oWindow.document.getElementsByTagName('frame')[1].contentWindow.document.getElementsByTagName('head').item(0);
var cssRef=oWindow.document.getElementsByTagName('frame')[1].contentWindow.document.createElement("link");
cssRef.setAttribute("rel", "stylesheet") ;
cssRef.setAttribute("type", "text/css");
cssRef.setAttribute("href", "x.css");
oHead.appendChild(cssRef);
oWindow.document.getElementsByTagName('frame')[1].contentWindow.document.body.innerHTML=oWindow.document.getElementsByTagName('frame')[1].contentWindow.document.body.innerHTML;
}
catch (err)
{
}
</script>
加上这个后,发现了另外一个问题,就是如果线有交叉,那么就只显示一条。
比如我们的模板是这样的(图比较丑,只是做个示例)
显示出来的效果是这样的
模板有4条斜线,实际上只显示了两条。
而他的HTML 代码就是本文最开始的那段。
明显是少了两条,经过试验,如果两条线有交叉
(不一定是视觉上的交叉,
交叉应该是以一条线为对角线,所在的矩形,与另一矩形有任何的交叉,都将会只显示一个矩形)
|