2

I have an excel on line documents that can be edited by users in the Excel 365 web application.

I have an application that read this excel file with the graph api.

I have successfully managed to read the data from the file but when a user change the excel file and Excel says it has been saved, if I read the file immediately with my application I have old data.

I have to wait for 30s to have the updated data. Is there anything I can do to avoid this latency.

Here is my call to get the data :

var range = await _graphClient.Drives[_driveId].Items[_itemId].Workbook.Worksheets[workseetName]
            .Range(rangeAddress).UsedRange(true)
            .Request()
            .GetAsync();
JuChom
  • 5,717
  • 5
  • 45
  • 78
  • Hi @juChom were you able find a workaround for this? – sid Apr 10 '23 at 07:16
  • @sid I think that the issue is not related to Graph API. I see the same delay when I have the file on SharePoint/OneDrive. After editing the excel (in the browser/in desktop app) it takes sometimes several minutes until the modified date column is updated. – user2250152 Apr 10 '23 at 11:44
  • 1
    We have further identified that issue is related to sessions. If we immediately close the excel file after manually updating, we get the updated values from api. – sid Apr 11 '23 at 06:40
  • I didn't have time to dig further – JuChom Apr 11 '23 at 07:54

1 Answers1

1

I posted a similar question on the graph API github repo. They responded here: https://github.com/microsoftgraph/msgraph-cli/issues/215#issuecomment-1379391739

They suggest using the etag property to determine whether the workbook has changed since that last access. https://learn.microsoft.com/en-us/graph/api/resources/driveitem?view=graph-rest-1.0

They also suggest using the Excel session. https://learn.microsoft.com/en-us/graph/api/resources/excel?view=graph-rest-1.0#sessions-and-persistence

However in my personal testing the session method didn't fix the delay in excel saving the data in the backend.

They also mentioned: "I cannot guarantee that these will work. I don't think this API was designed with real-time co-authoring in mind."

Owen Zhang
  • 11
  • 2
  • Hi Owen were you able find a workaround for this? – sid Apr 10 '23 at 07:17
  • Hey Sid, no workaround given on their side, a hack to get around this is to dedicate a cell with last update value and check that for every API update – Owen Zhang Apr 11 '23 at 14:11