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();
            }
        }
    }
}