天天看点

Rdlc报表由于reportviewer版本升级导致修改旧版报表后客户端无法打开

安装VS2017后,reportviewer另外下载安装的,繁体的,都没找到简体的。

修改原来的rdlc报表时,版本会不一样,导致客户端打印的时候报错。

Microsoft.Reporting.WinForms.LocalProcessingException: An error occurred during local report processing. ---> Microsoft.Reporting.DefinitionInvalidException: The definition of the report '' is invalid. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: The definition of this report is not valid or supported by this version of Reporting Services. The report definition may have been created with a later version of Reporting Services, or contain content that is not well-formed or not valid based on Reporting Services schemas. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition' which cannot be upgraded.

查看报表文件的时候发现

<?xml version="1.0" encoding="utf-8"?>

<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">

命名空间已经从

”http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition“

变成

”http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition“

为了和原来的版本保持一致,可以从报表文件的代码里面进行添加修改。

   <TablixRows>

                <TablixRow>

                  <Height>0.5cm</Height>

                  <TablixCells>

                    <TablixCell>

                      <CellContents>

                        <Textbox Name="textbox20">

                          <CanGrow>true</CanGrow>

                          <KeepTogether>true</KeepTogether>

                          <Paragraphs>

                            <Paragraph>

                              <TextRuns>

                                <TextRun>

                                  <Value>="哈哈(" &amp; First(Fields!ManageType.Value, "A") &amp; ")"</Value>

                                  <Style>

                                    <FontFamily>宋体</FontFamily>

                                  </Style>

                                </TextRun>

                              </TextRuns>

                              <Style />

                            </Paragraph>

                          </Paragraphs>

                          <rd:DefaultName>textbox20</rd:DefaultName>

                          <Style>

                            <BottomBorder>

                              <Color>Black</Color>

                              <Style>Solid</Style>

                              <Width>1pt</Width>

                            </BottomBorder>

                            <PaddingLeft>2pt</PaddingLeft>

                            <PaddingRight>2pt</PaddingRight>

                            <PaddingTop>2pt</PaddingTop>

                            <PaddingBottom>2pt</PaddingBottom>

                          </Style>

                        </Textbox>

                      </CellContents>

                    </TablixCell>

                    <TablixCell>

                      <CellContents>

                        <Textbox Name="textbox21">

                          <CanGrow>true</CanGrow>

                          <KeepTogether>true</KeepTogether>

                          <Paragraphs>

                            <Paragraph>

                              <TextRuns>

                                <TextRun>

                                  <Value>=format(First(Fields!PrescriptDate.Value, "A"),"yyyy年MM月dd日")</Value>

                                  <Style>

                                    <FontFamily>宋体</FontFamily>

                                  </Style>

                                </TextRun>

                              </TextRuns>

                              <Style />

                            </Paragraph>

                          </Paragraphs>

                          <rd:DefaultName>textbox21</rd:DefaultName>

                          <Style>

                            <BottomBorder>

                              <Color>Black</Color>

                              <Style>Solid</Style>

                              <Width>1pt</Width>

                            </BottomBorder>

                            <PaddingLeft>2pt</PaddingLeft>

                            <PaddingRight>2pt</PaddingRight>

                            <PaddingTop>2pt</PaddingTop>

                            <PaddingBottom>2pt</PaddingBottom>

                          </Style>

                        </Textbox>

                        <ColSpan>4</ColSpan>

                      </CellContents>

                    </TablixCell>

                    <TablixCell />

                    <TablixCell />

                    <TablixCell />

                  </TablixCells>

                </TablixRow>

注意增加行要在            <TablixRowHierarchy>节点下增加                <TablixMember>。否则会提示行数量不对。

    <TablixRowHierarchy>

              <TablixMembers>

                <TablixMember>

                  <KeepWithGroup>After</KeepWithGroup>

                  <KeepTogether>true</KeepTogether>

                </TablixMember>

                <TablixMember>

                  <KeepWithGroup>After</KeepWithGroup>

                  <KeepTogether>true</KeepTogether>

                </TablixMember>

2020-1-18 这两天将VS升级到2019了,然后又悲剧了一回。

虽然VS2019本身感觉挺好用的,但是reportviewer的问题真是坑死人。

我有些报表原本是引用了本地程序集,但是编译的时候无法加载程序集,这就很尴尬了,到现在也没解决,目前是先去掉引用,通过别的方式曲线救国。

过程:

安装完rdlc么有设计器,从扩展更新里面下载安装了最新rdlc设计器安装包。

Rdlc报表由于reportviewer版本升级导致修改旧版报表后客户端无法打开

从nuget里面下载了最新版的Microsoft.ReportingServices.ReportViewerControl.Winforms.150.1400.0和Microsoft.SqlServer.Types.14.0.314.76

编译的时候报错,框架问题,需要.net4.6, 我原本的是.net4.0,升级框架,解决问题,后面客户端升级可能就要一番功夫了。

经过测试,有了一个好处,修改rdlc命名空间会变成2016,但是打印不会出错误提示了。

就是引用自定义程序集出错有点烦,后续有解决了再更新。

继续阅读