question

VikasKrishnan-0374 avatar image
0 Votes"
VikasKrishnan-0374 asked saldana-msft edited

How to get a preview for an excel file stored in onedrive with an exact sheet from the workbook chosen ?

I need to preview a user uploaded excel file in my web application. From the Micorsoft Graph API to interact with Onedrive I could understand that I can get iFrame embed links either using createlink api or preview api.

Here I have an additional requirement to choose a particular sheet from the available multiple sheets in the work book when the preview is shown itself.

I have seen that the preview api has a parameter "page" to pass in body but could not see a positive change thought I had passed the probable inputs.

  1. For example I have a workbook sample.xlsx in onedrive.

  2. and workbook have sheet1 sheet2 and sheet3 as worksheets

  3. I am getting a preview embed link via preview api and embed it in an iframe.

  4. But this will show sheet3 as chosen by default. where I need to show sheet2.

Is there somehow I could acheive this via graph api ?

So can anyone help me in this with, is there a way to preview an excel file stored in one drive with a particular sheet selected or can we pass it in the api body?

microsoft-graph-filesmicrosoft-graph-explorermicrosoft-graph-workbooks
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JosephXu-MSFT avatar image
0 Votes"
JosephXu-MSFT answered JosephXu-MSFT commented

Hi@VikasKrishnan-0374 Per my test, we can use Worksheet: Range to preview specified worksheet.

  1. Following is my excel file in my onedrive.
    128213-image.png

  2. We can find its item id via https://graph.microsoft.com/v1.0/me/drive/root/children.
    128128-image.png

  3. We can specify the sheet name and range in this api https://graph.microsoft.com/v1.0/me/drive/items/{item-id}/workbook/worksheets('{sheet-name}')/range(address='A2:F11')?$select=values. We can see the values in my worksheet.
    128192-image.png



image.png (16.7 KiB)
image.png (9.8 KiB)
image.png (65.2 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @VikasKrishnan-0374 How are things going? Is there any update on your issue?

0 Votes 0 ·