|
From here you can easily add a button to export this report into PDF format. Let's do that next.
Step 1: Insert an Iron Speed Designer button into the CustomerPreviewReport layout page. Click on the
button. Look at the Quick HTML pane that is at the bottom of the screen. (if you can't see this, click View-HTML
Quick View from the Iron Speed Designer menu.
Step 2: Name the button "Export to PDF". Click Ok.
Build your Iron Speed Designer application so that your generated application knows about the name of
this button.
Step 3: With our button selected, right-click and select 'Add Code Customization'.
Click next past the welcome screen if present. You should now see a list of available code customizations
for this button:
Select 'Add custom' button and Handle its OnClick event. Click Next.
Select our ExportToPDF button and click Next. Then click Finish. Now your code framework has been
inserted into the safe class for this layout page.
Now we need to include code to generate our PDF document from our ActiveReports report. First, however,
we need to tell .NET about using ActiveReports. To do this, we need to put an Imports statement at the top
of the safe class page as shown below:
Okay, now that this done, let’s move back down to the code that the wizard inserted. We want to type the
following lines just after the phrase ' Add business logic for OnClick event.
So then our code block should look something like this:
Build your application in Iron Speed Designer again. This time, however, we note that there are errors. I take you in this direction because I want you to see what happens when we forget to add a required reference. In this case, the export library for ActiveReports is needed but has not been referenced in our Visual Studio project.
So why did we not get this error when we added our ActiveReports report? Well, .NET added the libraries we needed for the report when we dragged the WebViewer into our .ASPX page. But we didn’t get the chance to do that with our export to PDF code.
Okay, so back to Visual Studio we go. If you get a message like this:
Then just click ‘Yes to All’.
Now go over to Solutions Explorer in Visual Studio and expand the references area for our solution. You
can do this by clicking on the plus sign. Note the ActiveReports references that have already been added
for us.
Left click references. Then right-click references and select 'Add Reference'. Scroll down the list
until you see Data Dynamics references. You may have to widen the column to see everything.
Select the Data Dynamics ActiveReports PDF Export Filter reference and click ‘Select’. Click Ok.
Now we have our reference!
Let’s rebuild our project:
And run our project. This time it should compile successfully.
And then you should see this:
With a little more work and imagination you could turn this into a very sophisticated looking and
acting reporting mechanism. There are other reporting formats like Rich Text Format (RTF), Export
to Excel and a lot more...Any report format contained within our WebViewer is fair game for our Export
process.
|