locked
Can't refresh Excel Service programatically ? RRS feed

  • Question

  • Hi Folks,

    I am using MOSS/Excel 2007.

    I am trying to get updates in my Excel Web Access Webpart when Sharepoint list change. So, i am trying to do it with Excel Web Service API's. However, I am not getting updates in Workbook. Below is my code:

     

                    xlService.Timeout = 600000;

                    xlService.Credentials = System.Net.CredentialCache.DefaultCredentials;

                    string lstrWorkbookPath = "http://server/sites/Practice/test/Shared%20Documents/test5.xlsx";

                    string sessionID = xlService.OpenWorkbook(lstrWorkbookPath, "en-US", "en-US", out status);

                    xlService.Refresh(sessionID, null);

                    byte[] workBookSnapshot = xlService.GetWorkbook(sessionID, ExcelWebServiceAPI.ExcelService.WorkbookType.FullWorkbook, out status);

                   //status is coming null

                    status = xlService.CloseWorkbook(sessionID);

                   //status is coming null

                    BinaryWriter binaryWriter = new BinaryWriter(new FileStream(@"C:\SnapShot.xlsx", FileMode.Append));

                    binaryWriter.Write(workBookSnapshot);

                    binaryWriter.Close();

    I also have 1 connection in workbook which is exported to Data Connection Library. I also approve it as i am site coll. admin. on my site.

    When i open workbook in C:\, i don't get updates. But, when i click on Refresh button (in Data menu) in workbook, i get updates. I need updates without clicking on Refresh button. Is there any problem with Session timeout? Please advise.

     

    - Chintan



    • Edited by Mike Walsh FIN Monday, May 2, 2011 12:57 PM time pressure removed
    Monday, May 2, 2011 12:34 PM

All replies

  • Hi,

    Thanks to share your post.

    For the issue, my suggestion is to try to shorten the session timeout. And then close the workbook. Then reopen the workbook.

    Hope this could help you!

    Leo

    • Marked as answer by Emir Liu Monday, May 9, 2011 9:47 AM
    • Unmarked as answer by Harry Yuan Thursday, June 9, 2011 8:18 AM
    Wednesday, May 4, 2011 7:57 AM
  • Hi Chintan,

    Does it worked for you, if so can you please post the code or help me on the same issue?

    Thanks


    Best Regards, G Vijai Kumar | My Sharepoint Blog
    Wednesday, May 18, 2011 9:09 AM