Hi,
I have added extensions to local reports using Aspose.Words. i want to export my report to pdf and docx format. I have few queries regarding how to render report as docx:
- In rdlc file i used table and list to display records everything works fine if i export them in pdf format. But when i export report in docx format unnecessary borders and table/list borders become visible whereas in pdf report border are not visible.
- How can i add extension for docx in MS Sql Server reports(RDL) ?
I used following meathod for local reports:
private static void AddExtension(this LocalReport report, string name, string localizedName, Type extensionType)
{
const BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
// CommonService.ListRenderingExtension is an internal method that returns a list of supported
// rendering extensions. This list is also stored in a class field so we can simply get this list
// and add Aspose.Words for Reporting Services rendering extensions to make Microsoft Word
// export formats appear on the dropdown.
// Get the service type.
FieldInfo previewService = report.GetType().GetField("m_previewService", flags);
// Get the ListRenderingExtensions method info.
MethodInfo listRenderingExtensions = previewService.FieldType.GetMethod("ListRenderingExtensions", flags);
// Obtan a list of existing rendering extensions.
IList extensions = listRenderingExtensions.Invoke(previewService.GetValue(report), null) as IList;
// LocalRenderingExtensionInfo is a class that holds information about a rendering extension.
// We should create an instance of this class to add the info about the specified extension.
// Since the IRenderingExtension interface is defined in the Microsoft.ReportViewer.Common
// assembly, use this trick to obtain the corresponding Assembly instance. This will work for
// both Report Viewer 2005 (8.0) and 2008 (9.0).
Assembly commonAssembly = typeof(Microsoft.ReportingServices.ReportRendering.IRenderingExtension).Assembly;
// Now, get the LocalRenderingExtensionInfo type as it is defined in the same assembly.
Type localRenderingExtensionInfoType = commonAssembly.GetType("Microsoft.Reporting.LocalRenderingExtensionInfo");
// Get the LocalRenderingExtensionInfo constructor info.
ConstructorInfo ctor = localRenderingExtensionInfoType.GetConstructor(flags,
null,
new Type[] { typeof(string), typeof(string), typeof(bool), typeof(Type), typeof(bool) },
null);
// Create an instance of LocalRenderingExtensionInfo.
object instance = ctor.Invoke(new object[] { name, localizedName, true, extensionType, true });
// Finally, add the info about our rendering extension to the list.
extensions.Add(instance);
}
but it gives error message when i tried similar method for server reports.
- Can DocxRenderer be used to render report as docx files ? any code sample will be helpfull.