Click here to Skip to main content
15,891,204 members
Articles / Productivity Apps and Services / Microsoft Office

Adding DOC, RTF, and OOXML Export Formats to the Microsoft Report Viewer Control: Implementing It Easier Using Private Reflection

Rate me:
Please Sign up or sign in to vote.
4.85/5 (12 votes)
18 Aug 2008CPOL11 min read 85.1K   1.1K   66  
By following the steps outlined in this article, you will be able to get Report Viewer to generate reports in Microsoft Word formats (DOC, RTF, WordprocessingML, and OOXML) when working in the local mode.
  .method public hidebysig virtual instance class [mscorlib]System.Collections.Generic.IEnumerable`1<class Microsoft.Reporting.LocalRenderingExtensionInfo> 
          ListRenderingExtensions() cil managed
  {
    // Code size       403 (0x193)
    .maxstack  41
    .locals init (class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo> V_0,
             class Microsoft.ReportingServices.Rendering.HtmlRenderer.Html40RenderingExtension V_1,
             class Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer V_2,
             class [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.DocRenderer V_3,
             class [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.RtfRenderer V_4,
             class [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.WordMLRenderer V_5,
             class [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.DocxRenderer V_6,
             class Microsoft.ReportingServices.Rendering.ImageRenderer.RemoteGdiReport V_7,
             class Microsoft.ReportingServices.Rendering.ImageRenderer.ImageReport V_8,
             class Microsoft.ReportingServices.Rendering.ImageRenderer.PdfReport V_9)
    IL_0000:  ldarg.0
    IL_0001:  ldfld      class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo> Microsoft.Reporting.ControlService::m_renderingExtensions
    IL_0006:  brtrue     IL_018c

    IL_000b:  newobj     instance void class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo>::.ctor()
    IL_0010:  stloc.0
    IL_0011:  newobj     instance void Microsoft.ReportingServices.Rendering.HtmlRenderer.Html40RenderingExtension::.ctor()
    IL_0016:  stloc.1
    IL_0017:  ldloc.0
    IL_0018:  ldstr      "HTML4.0"
    IL_001d:  ldloc.1
    IL_001e:  callvirt   instance string Microsoft.ReportingServices.Rendering.HtmlRenderer.RenderingExtensionBase::get_LocalizedName()
    IL_0023:  ldc.i4.0
    IL_0024:  ldtoken    Microsoft.ReportingServices.Rendering.HtmlRenderer.Html40RenderingExtension
    IL_0029:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    IL_002e:  ldc.i4.0
    IL_002f:  newobj     instance void Microsoft.Reporting.LocalRenderingExtensionInfo::.ctor(string,
                                                                                              string,
                                                                                              bool,
                                                                                              class [mscorlib]System.Type,
                                                                                              bool)
    IL_0034:  callvirt   instance void class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo>::Add(!0)
    IL_0039:  newobj     instance void Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer::.ctor()
    IL_003e:  stloc.2
    IL_003f:  ldloc.0
    IL_0040:  ldstr      "Excel"
    IL_0045:  ldloc.2
    IL_0046:  callvirt   instance string Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer::get_LocalizedName()
    IL_004b:  ldc.i4.1
    IL_004c:  ldtoken    Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer
    IL_0051:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    IL_0056:  ldc.i4.1
    IL_0057:  newobj     instance void Microsoft.Reporting.LocalRenderingExtensionInfo::.ctor(string,
                                                                                              string,
                                                                                              bool,
                                                                                              class [mscorlib]System.Type,
                                                                                              bool)
    IL_005c:  callvirt   instance void class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo>::Add(!0)
    IL_0061:  newobj     instance void [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.DocRenderer::.ctor()
    IL_0066:  stloc.3
    IL_0067:  ldloc.0
    IL_0068:  ldstr      "AWDOC"
    IL_006d:  ldloc.3
    IL_006e:  callvirt   instance string [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.DocRenderer::get_LocalizedName()
    IL_0073:  ldc.i4.1
    IL_0074:  ldtoken    [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.DocRenderer
    IL_0079:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    IL_007e:  ldc.i4.1
    IL_007f:  newobj     instance void Microsoft.Reporting.LocalRenderingExtensionInfo::.ctor(string,
                                                                                              string,
                                                                                              bool,
                                                                                              class [mscorlib]System.Type,
                                                                                              bool)
    IL_0084:  callvirt   instance void class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo>::Add(!0)
    IL_0089:  newobj     instance void [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.RtfRenderer::.ctor()
    IL_008e:  stloc.s    V_4
    IL_0090:  ldloc.0
    IL_0091:  ldstr      "AWRTF"
    IL_0096:  ldloc.s    V_4
    IL_0098:  callvirt   instance string [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.RtfRenderer::get_LocalizedName()
    IL_009d:  ldc.i4.1
    IL_009e:  ldtoken    [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.RtfRenderer
    IL_00a3:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    IL_00a8:  ldc.i4.1
    IL_00a9:  newobj     instance void Microsoft.Reporting.LocalRenderingExtensionInfo::.ctor(string,
                                                                                              string,
                                                                                              bool,
                                                                                              class [mscorlib]System.Type,
                                                                                              bool)
    IL_00ae:  callvirt   instance void class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo>::Add(!0)
    IL_00b3:  newobj     instance void [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.WordMLRenderer::.ctor()
    IL_00b8:  stloc.s    V_5
    IL_00ba:  ldloc.0
    IL_00bb:  ldstr      "AWWML"
    IL_00c0:  ldloc.s    V_5
    IL_00c2:  callvirt   instance string [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.WordMLRenderer::get_LocalizedName()
    IL_00c7:  ldc.i4.1
    IL_00c8:  ldtoken    [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.WordMLRenderer
    IL_00cd:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    IL_00d2:  ldc.i4.1
    IL_00d3:  newobj     instance void Microsoft.Reporting.LocalRenderingExtensionInfo::.ctor(string,
                                                                                              string,
                                                                                              bool,
                                                                                              class [mscorlib]System.Type,
                                                                                              bool)
    IL_00d8:  callvirt   instance void class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo>::Add(!0)
    IL_00dd:  newobj     instance void [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.DocxRenderer::.ctor()
    IL_00e2:  stloc.s    V_6
    IL_00e4:  ldloc.0
    IL_00e5:  ldstr      "AWDOCX"
    IL_00ea:  ldloc.s    V_6
    IL_00ec:  callvirt   instance string [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.DocxRenderer::get_LocalizedName()
    IL_00f1:  ldc.i4.1
    IL_00f2:  ldtoken    [Aspose.Words.ReportingServices]Aspose.Words.ReportingServices.DocxRenderer
    IL_00f7:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    IL_00fc:  ldc.i4.1
    IL_00fd:  newobj     instance void Microsoft.Reporting.LocalRenderingExtensionInfo::.ctor(string,
                                                                                              string,
                                                                                              bool,
                                                                                              class [mscorlib]System.Type,
                                                                                              bool)
    IL_0102:  callvirt   instance void class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo>::Add(!0)
    IL_0107:  newobj     instance void Microsoft.ReportingServices.Rendering.ImageRenderer.RemoteGdiReport::.ctor()
    IL_010c:  stloc.s    V_7
    IL_010e:  ldloc.0
    IL_010f:  ldstr      "RGDI"
    IL_0114:  ldloc.s    V_7
    IL_0116:  callvirt   instance string Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRendererBase::get_LocalizedName()
    IL_011b:  ldc.i4.0
    IL_011c:  ldtoken    Microsoft.ReportingServices.Rendering.ImageRenderer.RemoteGdiReport
    IL_0121:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    IL_0126:  ldc.i4.0
    IL_0127:  newobj     instance void Microsoft.Reporting.LocalRenderingExtensionInfo::.ctor(string,
                                                                                              string,
                                                                                              bool,
                                                                                              class [mscorlib]System.Type,
                                                                                              bool)
    IL_012c:  callvirt   instance void class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo>::Add(!0)
    IL_0131:  newobj     instance void Microsoft.ReportingServices.Rendering.ImageRenderer.ImageReport::.ctor()
    IL_0136:  stloc.s    V_8
    IL_0138:  ldloc.0
    IL_0139:  ldstr      "IMAGE"
    IL_013e:  ldloc.s    V_8
    IL_0140:  callvirt   instance string Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRendererBase::get_LocalizedName()
    IL_0145:  ldc.i4.0
    IL_0146:  ldtoken    Microsoft.ReportingServices.Rendering.ImageRenderer.ImageReport
    IL_014b:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    IL_0150:  ldc.i4.1
    IL_0151:  newobj     instance void Microsoft.Reporting.LocalRenderingExtensionInfo::.ctor(string,
                                                                                              string,
                                                                                              bool,
                                                                                              class [mscorlib]System.Type,
                                                                                              bool)
    IL_0156:  callvirt   instance void class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo>::Add(!0)
    IL_015b:  newobj     instance void Microsoft.ReportingServices.Rendering.ImageRenderer.PdfReport::.ctor()
    IL_0160:  stloc.s    V_9
    IL_0162:  ldloc.0
    IL_0163:  ldstr      "PDF"
    IL_0168:  ldloc.s    V_9
    IL_016a:  callvirt   instance string Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRendererBase::get_LocalizedName()
    IL_016f:  ldc.i4.1
    IL_0170:  ldtoken    Microsoft.ReportingServices.Rendering.ImageRenderer.PdfReport
    IL_0175:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    IL_017a:  ldc.i4.1
    IL_017b:  newobj     instance void Microsoft.Reporting.LocalRenderingExtensionInfo::.ctor(string,
                                                                                              string,
                                                                                              bool,
                                                                                              class [mscorlib]System.Type,
                                                                                              bool)
    IL_0180:  callvirt   instance void class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo>::Add(!0)
    IL_0185:  ldarg.0
    IL_0186:  ldloc.0
    IL_0187:  stfld      class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo> Microsoft.Reporting.ControlService::m_renderingExtensions
    IL_018c:  ldarg.0
    IL_018d:  ldfld      class [mscorlib]System.Collections.Generic.List`1<class Microsoft.Reporting.LocalRenderingExtensionInfo> Microsoft.Reporting.ControlService::m_renderingExtensions
    IL_0192:  ret
  } // end of method ControlService::ListRenderingExtensions

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions