In the 2007 version of Office Accounting we have added a reporting SDK. With this SDK you now have some new opportunities for integrating to the application:

·         Creating new report executors

·         Creating new native reports

·         Creating report UI add-ins

·         Launching Reports

·         Getting data from reports

 

All of these options opens up a lot of new cool opportunities, in this post I will focus on the first on the list and describe a bit about how to create a new report executor and also offer a few ideas as to what this can be used for.

 

Advantages

What you can do with an report executor is actually pretty simple but it still adds a lot of power. You can now add launch points in Office Accounting that will look like any other report in the application. When the user launches these reports you are in full control! Office Accounting will simply call one method in your Add-in and the rest is up to you.

 

 

 

As you are in full control after the executor is called, you can do anything! I can offer a few ideas but I’m sure we will see this used for all kinds of things…

·         Open Excel reports.

·         Open Access reports.

·         Create new reports in MS SQL reporting.

·         Open existing report in ISV solution.

·         Really there is no limit to the possibilities :o)

 

Implementing IReportExecutorV2

OK, it all sounds very nice but how do you do this? Well you can shortcut the implementation by using the templates as mentioned in a prior post in this blog (under add-in types simply select “External Report Add-in”), but creating a new executor is really very simple.

To create a new report executor you simply have to implement one interface: IReportExecutorV2

 

This interface has just three methods:

IReportDescriptorV2 ReportDescriptor { get; set; }

This property is used internally in Office Accounting to identify the report, simply put the descriptor that will be set in a variable and give it back in the get.

Image SampleBitmap { get; }

This is the bitmap that is shown in Office Accounting on the report bucket, basically you just return a bitmap if you want to show something there.

object ShowReport();

This is where all the action happens! This method is called when the used launches the report from the application. Basically whatever you want to launch you just launch in this method.

 

That’s it! This will create a new report, the rest of the work is just registering the add-in to the application (witch by the way should be very similar to other Office Accounting add-ins).

 

Creating a Driver IReportAddInDriverV2

To register the add-in in Office Accounting you need a driver. In the driver you will basically tell the application where you want the report to show up. If you create a bunch of reports you will only need one driver to register them all. (again you will be helped if you use the template)

 

This interface has two methods:

void CreateReportCategories(ISmallBusinessInstanceV2 smallBusinessInstance);

In this method you can create all the report categories you need for your reports. The report categories are the ones showing up on the left hand side in the report bucket. (In the bitmap above I have created a new one called “OAReportAddIn Reports”). You don’t have to create new categories as you can add your reports to the existing categories. However I recommend adding your reports to your own categories.

void CreateReportDescriptors(ISmallBusinessInstanceV2 smallBusinessInstance);

In this method you create your new report descriptors. For each report in Office Accounting there is a corrosponding report descriptor. This descriptor basically tells the application where to launch the report from. (In the bitmap above you see the a new report added where the caption of the descriptor is “OAReportAddIn”).

 

On top of this you  have to implement a IDriverFactoryV2 that can load your drivers and name your Add-in, and a IDriverInfo. I won’t go much into detail on this as an example will be generated if you use the template.

 

Tips

·         You can easily create very simple reports based on the OA SDK (like showing a list of customers in a grid). However if you need more than a simple list you may run into performance problems. The views in the SDK will pull a lot of rows into memory that you may want to filter out, and if you need to join information from different objects  it will be fairly expensive. If you want to do stuff like that you may want to query the database in stead.

·         Often when you add a report executor you will need a reference to the instance or to the database. You can get the instance from the IReportDescriptorV2 that is passed in. From this instance you can also get to the server and database name.