FastReport 加载Load(Stream) 模板内包含换行符不能展示

如下代码 当以FastReport 载入streams时 当模板内包含换行符时会导致不能正常生成pdf

cs 复制代码
System.Xml.XmlDocument newFrxXml= new System.Xml.XmlDocument();
newFrxXml.Load(fileName);

FastReport.Report report = new FastReport.Report();
 using (var memStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(newFrxXml.InnerXml)))
            {
                report.Load(memStream);
            }

原因:

通过XmlDocument加载后 换行符由十进制的值变成了16进制展示


=》


导致Fastreport不呢正常加载导致

XML 复制代码
--正常模板--
 <Styles>
    <Style Name="EvenRows" Fill.Color="191, 223, 255" Font="宋体, 9pt"/>
  </Styles>
  <Dictionary/>
  <ReportPage Name="PageReport" LeftMargin="0" TopMargin="0" RightMargin="0" BottomMargin="0" FirstPageSource="15" OtherPagesSource="15" Guides="0,718.2,14.17,51.97,61.42,146.47,155.92,193.72,203.17,231.52,240.97,278.77,288.22,326.02,524.47,581.17,590.62,704.02,222.07,335.47,401.62,515.02,411.07,14.18,99.23,269.33,23.63,108.68,184.28,354.37,363.83,439.43,448.88,524.48,533.93,609.53,618.98,694.58,307.12,382.72,373.27,458.32,477.23,515.03,571.73,637.88,647.33,704.03,529.2,604.8,595.35,708.75" Watermark.Font="宋体, 60pt">
    <ColumnHeaderBand Name="ColumnHeader" Width="793.8" Height="75.22" CanGrow="true" PrintOn="FirstPage">
      <ChildBand Name="Child1" Top="78.42" Width="793.8" Height="434.7">
        <TextObject Name="Text54" Left="137.03" Top="9.45" Width="396.9" Height="311.47" Text="xxx:&#13;&#10;xxx" Format="Date" Format.Format="" VertAlign="Center" Font="宋体, 10pt"/>
      </ChildBand>
    </ColumnHeaderBand>
    <PageFooterBand Name="PageFooter" Top="516.32" Width="793.8" Height="47.63" Fill.Color="White" Guides="37.8,56.7,75.6,47.25,94.5,9.45,28.35,9.45"/>
  </ReportPage>

--通过XmlDocument加载后模板--
<Styles>
		<Style Name="EvenRows" Fill.Color="191, 223, 255" Font="宋体, 9pt"/>
	</Styles>
	<Dictionary/>
	<ReportPage Name="PageReport" LeftMargin="0" TopMargin="0" RightMargin="0" BottomMargin="0" FirstPageSource="15" OtherPagesSource="15" Guides="0,718.2,14.17,51.97,61.42,146.47,155.92,193.72,203.17,231.52,240.97,278.77,288.22,326.02,524.47,581.17,590.62,704.02,222.07,335.47,401.62,515.02,411.07,14.18,99.23,269.33,23.63,108.68,184.28,354.37,363.83,439.43,448.88,524.48,533.93,609.53,618.98,694.58,307.12,382.72,373.27,458.32,477.23,515.03,571.73,637.88,647.33,704.03,529.2,604.8,595.35,708.75" Watermark.Font="宋体, 60pt">
		<ColumnHeaderBand Name="ColumnHeader" Width="793.8" Height="75.22" CanGrow="true" PrintOn="FirstPage">
			<ChildBand Name="Child1" Top="78.42" Width="793.8" Height="434.7">
				<TextObject Name="Text54" Left="137.03" Top="9.45" Width="396.9" Height="311.47" Text="xxx:&#xD;&#xA;xxx" Format="Date" Format.Format="" VertAlign="Center" Font="宋体, 10pt"/>
			</ChildBand>
		</ColumnHeaderBand>
		<PageFooterBand Name="PageFooter" Top="516.32" Width="793.8" Height="47.63" Fill.Color="White" Guides="37.8,56.7,75.6,47.25,94.5,9.45,28.35,9.45"/>
	</ReportPage>

解决办法:

cs 复制代码
 using (var memStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(newFrxXml.InnerXml.Replace("&#xD;", "&#13;").Replace("&#xA;", "&#10;"))))
            {
                report.Load(memStream);
            }
相关推荐
大磕学家ZYX6 分钟前
使用Nodejs尝试小程序后端服务编写:简单的待办事项管理demo
开发语言·javascript·小程序·node.js
先做个垃圾出来………10 分钟前
什么是装饰器?
开发语言·python
ComputerInBook15 分钟前
理解 C++ 的 this 指针
开发语言·c++·指针·this·this指针
我真不会起名字啊22 分钟前
Qt如何生成和使用DLL动态链接库
开发语言·qt
小马敲马1 小时前
[3.4] 集合通信 理论+代码
开发语言·c++·人工智能·算法·性能优化
杰_happy1 小时前
PHP Swoft2 框架精华系列:Config 配置解析,使用说明
开发语言·php
CodeCipher2 小时前
Java基础复习之继承
java·开发语言
BillKu2 小时前
Java延时
java·开发语言
雨师@2 小时前
ATM 模拟器 Golang 程序--示例
开发语言·后端·golang
向上的车轮3 小时前
语言特性适用的场景:卫星、火箭控制系统用什么开发语言?
java·开发语言·c++·c#·c·ada