Welcome to MSDN Blogs Sign in | Join | Help
More than one report in one Office Accounting add-in

I was asked If you need a new Report add-in for each report you want to add. I think it is a good question and one of the things you do not get for free in you generate your reports using the templates (there I had a chance to mention it again)

 

The answer is no, you can do that if you want to be able to install and remove them individually, but one driver can easily contain several reports.

The code you need to look at is the CreateReportDescriptors method in the ReportAddInDriver implementation (and the CreateReportCategories method if you want to add more than one report category).

Example:

public void CreateReportDescriptors(ISmallBusinessInstanceV2 smallBusinessInstance)

{

    if (smallBusinessInstance == null)

        throw new ArgumentNullException("smallBusinessInstance");

 

    IReportDescriptorV2 descriptor

        = smallBusinessInstance.CreateReportDescriptor("Report1", typeof(SBAReportAddInWithMoreReport1), SBAReportAddInWithMoreReport1.Guid);

    descriptor.Caption = "Report 1";

    descriptor.MappingType = ReportMappingType.NativeAddInRegistration;

    descriptor.Save();

    reportCategory.AddDescriptor(descriptor);

    descriptor = smallBusinessInstance.CreateReportDescriptor("Report2", typeof(SBAReportAddInWithMoreReport2), SBAReportAddInWithMoreReport1.Guid);

    descriptor.Caption = "Report 2";

    descriptor.MappingType = ReportMappingType.NativeAddInRegistration;

    descriptor.Save();

    reportCategory.AddDescriptor(descriptor);

}

Simple, right? Just add a couple of lines of code adding the new report...

Do not get confused by the GUID that you have to supply here, the GUID identifies the driver not the report (you have to specify the same GUID on the category). I probably would not have put it in the member in the SBAReportAddInWithMoreReport1 class :o)

Posted: Friday, June 22, 2007 1:21 AM by Jorn

Comments

don@dpdynamics.com said:

Thank Jorn

Works perfectly.  I moved the GUID from the report object (SBAReportAddInWithMoreReport1) to the driver per your suggestion.  This may be something they want to change in the template too.(Eliminate confusion when using multiple reports)

# June 22, 2007 11:10 AM
Anonymous comments are disabled
Page view tracker