2014-03-28 73 views
1

我在Visual Studio 2010中使用报表查看器。我有两个问题: 1.我无法将表格居中,它会自动对齐到左侧。 2.我想将数据对齐到表格中。我怎样才能做到这一点?ReportViewer的中心位置 - ASP.net

谢谢。 (这是我的报表查看器代码:)

Example

<asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 
    <div > 
     <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
      Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
      WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Height="800px" Width="100%" RightToLeft="YES"> 
      <LocalReport ReportPath="Report3.rdlc" > 
       <DataSources> 
        <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" /> 
       </DataSources> 
      </LocalReport> 
     </rsweb:ReportViewer> 
     <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
      SelectMethod="GetData" 
      TypeName="Shemen.ta2014DataSetTableAdapters.SoftwareTableAdapter"> 
     </asp:ObjectDataSource> 
    </div> 

回答

2

为中心的报告本身,尝试:

<center> 
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
        WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Height="800px" Width="100%" RightToLeft="YES"> 
    <LocalReport ReportPath="Report3.rdlc"> 
    <DataSources> 
     <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" /> 
    </DataSources> 
    </LocalReport> 
</rsweb:ReportViewer> 
</center> 

,以此作为调整的数据,你就必须通过选择列并设置“水平对齐”属性,在报表级别执行此操作。

我希望这会有所帮助。

+0

嗨,谢谢,但报告实际上在100%的页面上,你可以看到上面的工具栏。这是报告的一部分。所以我只需要将表格居中。 – user2097810

+0

我没有看到那部分。在这种情况下,您可以在报告中删除右侧的空白,也可以通过在右侧和左侧添加等量的填充来使表格居中。 –

+0

这帮了我,我设置了控件属性SizeToReportContent =“true”,然后将控件包装在

标签中,这正是我正在为我+1所寻找的。 –

0

刚刚遇到这个问题,发现它可以通过几行javascript来解决。享受

<script type="text/javascript"> 

window.onload = function() { 

     $('td#oReportCell', window.parent.frames[0].frames[1].document).next().remove(); 
     $('div#oReportDiv table', window.parent.frames[0].frames[1].document).attr("align", "center"); 
}; 

</script>