区域报表这么加载?
如题 新建区域报表如何加载?见一下示例代码:SectionReport report = new SectionReport();StringWriter w = new StringWriter();
XmlTextWriter xmlWriter = new XmlTextWriter(w)
{
Formatting = Formatting.Indented,
Indentation = 1,
IndentChar = '\t'
};
report.SaveLayout(xmlWriter);
string rpt = w.ToString();
byte[] data = Encoding.UTF8.GetBytes(rpt);
MemoryStream reportStream= new MemoryStream(data);
reportStream.Position = 0;
reportDesigner.LoadReport(XmlReader.Create(reportStream), DesignerReportType.Section);
这样加载不了 请问该怎么用代码处理呢?
参考博客:http://blog.gcpowertools.com.cn/post/enduserdesigner.aspx
public static void BuildSectionReportLayout(Design.Designer designer)
{
// 空白区域报表
string rpx = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <ActiveReportsLayout Version=\"3.2\" PrintWidth=\"9360\" DocumentName=\"ActiveReports Document\" ScriptLang=\"C#\" MasterReport=\"0\"> <StyleSheet> <Style Name=\"Normal\" Value=\"font-family: Arial; font-style: normal; text-decoration: none; font-weight: normal; font-size: 10pt; color: Black; text-align: left; vertical-align: top; ddo-char-set: 1\" /> <Style Name=\"Heading1\" Value=\"font-family: Arial; font-size: 16pt; font-style: normal; font-weight: bold\" /> <Style Name=\"Heading2\" Value=\"font-family: Times New Roman; font-size: 14pt; font-style: italic; font-weight: bold\" /> <Style Name=\"Heading3\" Value=\"font-family: Arial; font-size: 13pt; font-style: normal; font-weight: bold\" /> </StyleSheet> <Sections> <Section Type=\"PageHeader\" Name=\"PageHeader1\" Height=\"360\" BackColor=\"16777215\" /> <Section Type=\"Detail\" Name=\"Detail1\" Height=\"2880\" BackColor=\"16777215\" /> <Section Type=\"PageFooter\" Name=\"PageFooter1\" Height=\"360\" BackColor=\"16777215\" /> </Sections> <ReportComponentTray /> <PageSettings /> <Parameters /> </ActiveReportsLayout>";
// 区域报表数据源结构
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("Col1");
dt.Columns.Add("Col2");
dt.Columns.Add("Col3");
designer.Report = null;
// 加载区域报表到设计器
designer.LoadReport(XmlReader.Create(LayoutBuilder.CovertStringToStream(rpx)), DesignerReportType.Section);
// 设置区域报表数据源
SectionReport sr2 = designer.Report as SectionReport;
sr2.DataSource = dt;
}
Lenka.Guo 发表于 2017-5-9 10:35
参考博客:http://blog.gcpowertools.com.cn/post/enduserdesigner.aspx
LayoutBuilder是哪个类库下的,代码能具体点吧 类似我发出的代码 可以直接用的 上面给的博客链接中有源码下载,您可以看看。LayoutBuilder 是自定义类 Lenka.Guo 发表于 2017-5-9 10:59
上面给的博客链接中有源码下载,您可以看看。LayoutBuilder 是自定义类
byte[] data = Encoding.UTF8.GetBytes(rpt);
MemoryStream reportStream= new MemoryStream(data);
工具类只是写了这个而已 问题是我这么获取layout字符串;
StringWriter w = new StringWriter();
XmlTextWriter xmlWriter = new XmlTextWriter(w)
{
Formatting = Formatting.Indented,
Indentation = 1,
IndentChar = '\t'
};
report.SaveLayout(xmlWriter);
string rpt = w.ToString();
这样获取字符串会一直在加载 请问正确的写法是什么? 您是想把已经创建好的区域报表读到设计器当中?public static SectionReport AddDataSectionSetDataSource()
{
SectionReport report = new SectionReport();
report.LoadLayout("..\\..\\SectionReport2.rpx");
Data.OleDBDataSource ds = new Data.OleDBDataSource();
ds.ConnectionString = Properties.Resources.ConnectionString;
ds.SQL = Constants.cmdText;
report.DataSource = ds;
System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter("..\\..\\SectionReport2.rpx", null);
report.SaveLayout(xtw);
return report;
}
......
.....
...
SectionReport sr = LayoutBuilder.AddDataSectionSetDataSource();
reportDesigner.LoadReport(new FileInfo("..\\..\\SectionReport2.rpx"));
sr.Dispose();
Lenka.Guo 发表于 2017-5-9 12:02
您是想把已经创建好的区域报表读到设计器当中?
解决了 谢了
OK, Thanks your feedback Lenka.Guo 发表于 2017-5-9 12:08
OK, Thanks your feedback
ar9 区域报表怎么实现表格 动态行和动态列 以及单元格的边框 新问题发新帖
页:
[1]