本帖最后由 Lenka.Guo 于 2016-7-22 14:05 编辑
将数据库的流文件读取出来转换为TextReader类型 然后转换为PageReport.
1. 从数据库读取报表
- using (MemoryStream ms = new MemoryStream())
- {
- (ObjectReport as SectionReport).SaveLayout(ms);
- ms.Position = 0;
- using (StreamReader sr = new StreamReader(ms, Encoding.Unicode))
- {
- _dict.Add("CONTENT", sr.ReadToEnd());
- }
- }
复制代码 2. 将报表写入数据库
- using (MemoryStream ms = new MemoryStream())
- {
- using (StreamWriter sw = new StreamWriter(ms, Encoding.Unicode))
- {
- sw.Write(_dr["CONTENT"].ToString());
- sw.Flush();
- ms.Position = 0;
- //需要区分区域报表
- if (_dr["TYPE_ID"].ToString().Equals("4"))
- {
- m_Designer.LoadReport(XmlReader.Create(ms), DesignerReportType.Section);
- }
- else
- {
- m_Designer.LoadReport(XmlReader.Create(ms), DesignerReportType.Page);
- }
- }
- }
复制代码
|