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);
            }
相关推荐
百***0745几秒前
GPT-5.2:重构通用智能边界,迈向生产级AI新纪元
开发语言·python·gpt
froginwe111 分钟前
RDF 规则:构建语义网的基础
开发语言
_OP_CHEN3 分钟前
【从零开始的Qt开发指南】(二十三)Qt 界面优化之绘图实战:解锁自定义界面的无限可能
开发语言·qt
郝学胜-神的一滴9 分钟前
使用QVideoWidget实现高效视频播放:从基础到高级应用
开发语言·c++·qt·程序人生·音视频
秋漓9 分钟前
浏览器访问跨域
开发语言·lua
Cher ~10 分钟前
【数据结构】stl 容器
开发语言·数据结构·c++
老蒋每日coding17 分钟前
Go语言实现 Agent Demo
开发语言·后端·golang
czliutz20 分钟前
R语言gm音乐包的使用简单介绍
开发语言·r语言·音乐·技巧
爱吃泡芙的小白白25 分钟前
Qt 3D老树新花:为何在工业与车载领域仍是首选?
开发语言·qt·3d
余衫马26 分钟前
Qt for Python:PySide6 入门指南
开发语言·c++·python·qt