How to convert a ReportViewer report definition from 2016 to 2008
As stated in this answer on Stack Overflow, a version 2016 RDLC file can be converted to a version 2008 RDLC file by editing the xml like so:
Update Version 2016 to 2008 in first line.
Delete two lines of both opening and closing part of the ReportSection and ReportSections.
Delete complete ReportParametersLayout part.
Here is a script that be assigned to a macro in Microsoft Visual Studio 2019 to accomplish this quickly.
/// <reference path="C:\Users\keck.60a\AppData\Local\Microsoft\VisualStudio\16.0_f59d0164\Macros\dte.js" /> function replaceRegex(FindWhat, ReplaceWith) { dte.Find.Action = 4; // vsFindAction.vsFindActionReplaceAll; dte.Find.FindWhat = FindWhat; dte.Find.ReplaceWith = ReplaceWith; dte.Find.Target = 1; // vsFindTarget.vsFindTargetCurrentDocument; dte.Find.PatternSyntax = 1; // vsFindPatternSyntax.vsFindPatternSyntaxRegExpr; dte.Find.ResultsLocation = 0; // vsFindResultsLocation.vsFindResultsNone; dte.Find.Action = 4; // vsFindAction.vsFindActionReplaceAll; dte.Find.Execute(); } replaceRegex('<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">', '<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">'); replaceRegex('<ReportSections>', ''); replaceRegex('<ReportSection>', ''); replaceRegex('</ReportSection>', ''); replaceRegex('</ReportSections>', ''); replaceRegex('<ReportParametersLayout>.*(.*\n)*.*</ReportParametersLayout>', '');
-
- Install the Macros for Visual Studio extension.
- Go to Tools -> Macro Explorer.
- Add a new macro, paste in this code, and save.
- Open your version 2008 RDLC file.
- Right-click your new macro in the Macro Explorer and select Playback.
THANK YOU! 1) I had no idea that macros had returned to visual studio. 2) Editing the rdlc after every save was driving me nuts.
Thanks a lot!!! This saves manual re-editing of the rdlc