日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

将RDL报表转换成RDLC报表的函数

發布時間:2023/12/20 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 将RDL报表转换成RDLC报表的函数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
原文:將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);// 創建一個根節點ReportXmlElement 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报表的函数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。