|Country:||Central African Republic|
|Published (Last):||21 December 2014|
|PDF File Size:||9.83 Mb|
|ePub File Size:||12.18 Mb|
|Price:||Free* [*Free Regsitration Required]|
With the release of ActiveReports 7, we have provided users of Data Dynamics Reports and ActiveReports with an upgrade that adds significant new features. When we were creating the new viewer control, one thing we didn't bring over from Data Dynamics Reports was a built-in export from the viewer.
This is largely because the number of toolbar buttons on the viewer is already staggering. If you want to export the current report, we expose an Export method on the viewer control. In a future release we'll add the export option to the standalone designer and viewer applications as well. But that doesn't help if you want to provide that functionality now and you don't want to write the code from scratch.
Well, when we're done with this post, you'll have a class that will create a toolbar button for you to provide exports to your users. If you are not using VS, you can just copy the classes out of the project and add the bitmap resource image. Let's get to it! If you look at the signature of the Export method you'll see that it takes just a few parameters: an object implementing IDocumentExportEx, the destination FileInfo or Stream, and, optionally, the page range.
We'll make use of this to implement the export functionality. Despite the name, these exports can handle both SectionDocument and PageDocument reports, because internally they convert a PageDocument into a SectionDocument at run time. Something important that we considered in our design was that you may not want to ship all of the exports with your application.
That is why we provide two ways of excluding exports that do not require you to modify the toolbar button code at all. Let's start by looking at how to implement a single export. If you open the project, you'll find the SectionReportExporter class. This abstract class provides the base capability to load up the export type at run time, and it returns the IDocumentExportEx object that does the exporting. It also provides some helper properties that the UI uses to provide a file dialog filter and default extension.
You may also notice an Export method that will allow you to do more advanced exports in the future, but for now, these stubs throw a NotImplementedException. The reflection code is fairly basic: we take in the type name and use Type.
GetType to load it at runtime. If it fails, then we know to hide the toolbar button. Once we have the type, we can use the Activator class to create an instance of it, and return it from the GetExporter method as an implementation of IDocumentExportEx. Each of the exports inherits from this class and passes in the type name, and returns the appropriate file dialog values.
Now that we have the IDocumentExportEx object, we can use it in the toolbar button. This creates our Save As dialog, passes in our exporter's preferred file filter and default extension, and then calls the Export method of the viewer control, or "host" in this method. The rest of the code in the project deals with the management of the allowed exports and filters out any exports that aren't available at runtime. I've made it easy to use this code in your own project. Add the toolbar button image resource, and then the classes.
Once you add those to your project, you can add the button with code like the following:. The button loads up the available exports at run time.
If you want to remove some from the list, you can modify the AvailableExports dictionary on the button see the commented out code above before you add the button to the toolstrip.
If you were to use this same code in the button click event, the exports you remove would still display if the user dropped down the list without clicking the button. I hope you find this code useful. I plan on maintaining it with additional features and bug fixes as we make changes to ActiveReports 7 in the future. Stay up to date with the GrapeCity feeds.
For more information, contact Caitlyn Depp at press grapecity. Search Cart My Account. NET Web Forms. Resources Documentation Technical Support Blogs. Back Spread Products Spread. A collection that you can modify at runtime to remove exports that you don't want to make available.
Runtime-checking to ensure that each export is available prior to displaying the list to the user. DefaultExtension; saveAsDlg. FileDialogFilter; if saveAsDlg. ShowDialog host! OK return; host. Export exporter, new FileInfo saveAsDlg. Remove "PDF" ; viewer1. Insert 3, button ; The button loads up the available exports at run time. Login to post a comment. Technologies Web. Contact For more information, contact Caitlyn Depp at press grapecity.
All Rights Reserved.
GrapeCity ActiveReports is a set of assemblies that enable you to create, render, print, and export reports in a. NET or. NET Core application. This package includes assemblies needed to display reports in report viewers. Multiple viewers are included for your convenience.
Subscribe to RSS
With the release of ActiveReports 7, we have provided users of Data Dynamics Reports and ActiveReports with an upgrade that adds significant new features. When we were creating the new viewer control, one thing we didn't bring over from Data Dynamics Reports was a built-in export from the viewer. This is largely because the number of toolbar buttons on the viewer is already staggering. If you want to export the current report, we expose an Export method on the viewer control. In a future release we'll add the export option to the standalone designer and viewer applications as well.