How to refresh Deski report and export it as PDF and XLS using COM SDK

Here is an example how to open Deski report and refresh it and export as PDF using COM SDK.

You will need Visual Studio 2010 Express, BusinessObjects Enterprise XI 3.1 client tools.

1) Create a Deski report (here C:\Users\dmytro\Desktop\Document1.rep)
2) Create a new Project “RunDeski” in VS
3) Add reference to the Deski COM SDK, Project > Add Reference > BusinessObjects 12.0 Object Library
4) Paste the code.
5) Run it.

using busobj;
namespace RunDeski
{
    class Program
    {
        static void Main(string[] args)
        {
            Application application = new Application();
            try 
            {
                application.Interactive = false;
                application.Logon("Administrator", "", "localhost", "secEnterprise", false, true);
                IDocument doc = application.Documents.Open(@"C:\Users\dmytro\Desktop\Document1.rep");
                doc.Refresh();
                doc.ExportAsPDF(@"C:\Users\dmytro\Desktop\Document1.pdf"); 
                doc.SaveAs(@"C:\Users\dmytro\Desktop\Document1.xls");
                doc.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                application.Quit();
            }
        }
    }
}

12 thoughts on “How to refresh Deski report and export it as PDF and XLS using COM SDK

    1. dmytro Post author

      I assume you can get some information using COM SDK. You can find document “BusinessObjects SDK Object Model Diagrams” on the web, which has class diagrams. Document -> Reports -> Report -> SectionStructure -> ReportStructureItems -> ReportStructureItem. Item has property Type which indicates whether it is cell, table, chart or crosstab; and you can cast the object to BlockStructure and then get Pivot which has properties like rows, columns. (I do not have a code sample for this.)

      Like

      Reply
      1. Induja

        I tried as you suggested. I could retrieve the Report structure item’s type now and while trying to cast to BlockStructure i get an error, unable to cast object. can u help?

        Like

      2. dmytro Post author

        ReportStructureItem can be instance of CellStructure or BlockStructure. So you need to add checking of the instance type.
        C#:

        if (item is BlockStructure) ...

        VB:

        If TypeOf item Is BlockStructure Then ...

        Like

      1. dmytro Post author

        No. It is only for Deski reports. You will get an error something like: System.Runtime.InteropServices.COMException (0x00000088): Unable to open this document, file is corrupted

        Like

  1. Induja

    Hi,
    I am trying to open deski report in server using
    IDocument doc = application.Documents.OpenFromEnterprise(“test”,”Deski”,0);
    test is my report name, and Deski is the folder name where report exists and its under public folders.
    While executing i get error stating ” Document not found on repository”. I could import the same file using my client tool ,so guess there is no problem with my access to server.
    Could you please help…

    Like

    Reply
  2. Geert Van Der Streeck

    Thanks for the example. We are going to analyse +100.000 Deski reports, before we start the migration to BI4. 🙂

    We try to use the file busobj.tlb in Visual Studio but we can not use these files as references. Do we have to treat these files and convert them into .dll’s? Thanks for the feedback.

    Like

    Reply
    1. dmytro Post author

      I believe busobj should be exe file. Don’t you have COM library as described above? Do you have client tools installed on your machine?

      Like

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s