原文:将RDL报表转换成RDLC报表的函数

    近日研究RDLC报表,发现其不能与RDL报表兼容,尤其是将RDL报表转换成RDLC报表。网上的资料贴出的的转换方式复杂且不切实际,遂决定深入研究。经研究发现,RDL报表与RDLC报表的XML格式有些差异,将RDL报表的XML格式改成与RDLC报表的XML格式相同,发现转换成功! 如需转换123.rdl文件,只需RDLConvertRDLC("123.rdl"),即可转换成123.rdlc文件。由于本人对带命名空间的XML文件操作不熟悉,不能将除根节点意外的其他节点的xmlns属性只去掉,如有高手,欢迎指教!
        private void RDLConvertRDLC(string strFile)
{
if(File.Exists(strFile))
{
try
{
XmlDocument xmlBak;
XmlNamespaceManager nsMgrBak;
XmlNodeList Reports; // 打开需转换的XML文件
try
{
xmlBak = new XmlDocument();
xmlBak.Load(strFile);
nsMgrBak = new XmlNamespaceManager(xmlBak.NameTable);
nsMgrBak.AddNamespace("nsBak", "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition");
Reports = xmlBak.SelectSingleNode("/nsBak:Report", nsMgrBak).ChildNodes;
}
catch
{
File.Move(strFile, strFile + "c");
return;
} // 创建新的XML文件
XmlDocument xmlDoc = new XmlDocument();
XmlDeclaration dec = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
xmlDoc.AppendChild(dec); // 创建一个根节点Report
XmlElement root = xmlDoc.CreateElement("Report");
root.SetAttribute("xmlns:rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner");
root.SetAttribute("xmlns", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition");
xmlDoc.AppendChild(root); // 拷贝节点数据到新XML文件
for (int i = 0; i < Reports.Count; i++)
{
if (Reports[i].Name != "AutoRefresh")
{
if (Reports[i].Name == "ReportSections")
{
XmlNodeList ReportSections = xmlBak.SelectSingleNode("/nsBak:Report/nsBak:ReportSections/nsBak:ReportSection", nsMgrBak).ChildNodes;
for (int j = 0; j < ReportSections.Count; j++)
{
XmlElement newElement = (XmlElement)xmlDoc.ImportNode(ReportSections[j], true);
newElement.SetAttribute("xmlns", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition");
root.AppendChild(newElement);
}
}
else
{
XmlElement newElement = (XmlElement)xmlDoc.ImportNode(Reports[i], true);
newElement.SetAttribute("xmlns", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition");
root.AppendChild(newElement);
}
}
}
xmlDoc.Save(@strFile + "c");
File.Delete(strFile);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
MessageBox.Show("文件"+strFile+"不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

将RDL报表转换成RDLC报表的函数的更多相关文章

  1. 只需2分钟!PC端的报表即可转换成手机报表

    转: 只需2分钟!PC端的报表即可转换成手机报表 手机制作报表,这个大家不知有没有尝试过,虽然我们平时都用电脑做,但是电脑要是不在身边了,手机就可以用来应应急.但其实小编并没有在手机上制作报表的实践经 ...

  2. PHP 数字金额转换成中文大写金额的函数 数字转中文

    /** *数字金额转换成中文大写金额的函数 *String Int $num 要转换的小写数字或小写字符串 *return 大写字母 *小数位为两位 **/ function num_to_rmb($ ...

  3. VB中将INT型转换成STRING和从STRING转换成INT型的函数

    CStr 函数示例本示例使用 CStr 函数将一数值转换为 String. Dim MyDouble, MyStringMyDouble = 437.324   ' MyDouble 为 Double ...

  4. 算法练习-字符串转换成整数(实现atoi函数)

    练习问题来源 https://leetcode.com/problems/string-to-integer-atoi/ https://wizardforcel.gitbooks.io/the-ar ...

  5. 如何将jsp页面的table报表转换到excel报表导出

    假设这就是你的jsp页面: 我们会添加一个“导出到excel”的超链接,它会把页面内容导出到excel文件中.那么这个页面会变成这个样子 在此,强调一下搜索时关键词的重要性,这样一下子可以定位到文章, ...

  6. XE3随笔16:将字符串转换成 UTF8 编码的函数

    这种转换一般用于网页地址; 我不知道 Delphi 是不是有现成的函数, 用到了就写了一个. //函数: function ToUTF8Encode(str: string): string; var ...

  7. SQLSERVER金额转换成英文大写的函数

    CREATE FUNCTION [dbo].[f_num_eng] (@num numeric(15,2)) RETURNS varchar(400) WITH ENCRYPTION AS BEGIN ...

  8. ORACLE金额转换成英文大写的函数

    用法如下:get_capital_money(Currency, Money) Currency: 货币或货币描述,将放在英文大写的前面: Money:金额.支持两位小数点.如果需要更多的小数点,请自 ...

  9. 动态生成RDLC报表

    前段时间,做了RDLC报表,主要是三块功能: 1.从DataGrid提取(包括最新的增删改)的数据,自动生成对应的RDLC报表文件(以流的形式驻存在内存中),用ReportViewer类来展示.打印. ...

随机推荐

  1. IdentityServer4实战 - JWT Token Issuer 详解

    原文:IdentityServer4实战 - JWT Token Issuer 详解 一.前言 本文为系列补坑之作,拖了许久决定先把坑填完. 下文演示所用代码采用的 IdentityServer4 版 ...

  2. Spring ContextLoaderListener与DispatcherServlet所加载的applicationContext的区别

    http://www.lai18.com/content/9755931.html Spring 容器(Spring 的上下文) https://my.oschina.net/jast90/blog/ ...

  3. mysql使用substring_index达到splite功能

    函数: 1.从左开始截取字符串 left(str, length) 说明:left(被截取字段,截取长度) 例:select left(content,200) as abstract from my ...

  4. 文件上传api——MultipartFile

    MultipartFile 方法总结  byte[] getBytes() 返回文件的内容作为一个字节数组.  String getContentType() 返回文件的内容类型.  InputStr ...

  5. 怎么样Windows7在配置ASPserverIIS

    在百度经验浏览:http://jingyan.baidu.com/article/5553fa82ed97c765a23934f3.html Internet Information Services ...

  6. KindEditor4.1.10,支持粘贴图片

    转载自https://blog.csdn.net/jimmy0021/article/details/73251406 我已经忘记我是不是从这个博主的那里找到的解决kindeditor粘贴图片的方法了 ...

  7. HTTP协议中的报文格式

    按照传输过程,HTTP 报文分为请求报文和响应报文.请求报文和响应报文的结构差不多,这里只对 HTTP 请求报文做一个总结.HTTP 请求报文由 请求行.请求头.请求体(请求数据).空行 四个部分组成 ...

  8. 再议指针---------函数回调(qsort函数原理)

    我们是否能写一个这种函数: 能够对不论什么类型数据排序 不论什么人在使用该函数不须要改动该函数代码(即:用户能够不必看到函数源 码,仅仅会调用即可) 思考: 用户须要排序的数据的类型千变万化,可能是i ...

  9. JieBaNet+Lucene.Net

    基于JieBaNet+Lucene.Net实现全文搜索   实现效果: 上一篇文章有附全文搜索结果的设计图,下面截一张开发完成上线后的实图: 基本风格是模仿的百度搜索结果,绿色的分页略显小清新. 目前 ...

  10. 11991 - Easy Problem from Rujia Liu?(的基础数据结构)

    UVA 11991 - Easy Problem from Rujia Liu? 题目链接 题意:给一个长度n的序列,有m询问,每一个询问会问第k个出现的数字的下标是多少 思路:用map和vector ...