Share via

Sharepoint with Excel & Javascript read, edit & save

Dariusz Biskupski 1 Reputation point
2022-01-07T19:57:39.33+00:00

Hi

I am making HTML & CSS site on Sharepoint which will be saved as .aspx file. I want it to have a form so many people will be able to save it to one Excel. Each person submission would add new row and save the file. Another website would be pulling the content of this Excel and displaying it also on HTML, CSS page. I want to use JavaScript to do so. I see some external libraries to read the file and display on a page - this works fine, but the problem is with updating & saving the existing excel. Please help.

Regards
Dariusz

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    2022-01-10T02:50:28.21+00:00

    Hi @Dariusz Biskupski
    I will recommend you to use graph api to edit Excel file. Here is the example to refer

    const options = {  
    	authProvider,  
    };  
      
    const client = Client.init(options);  
      
    const workbookTableRow = {  
      values: "[  
        [1, 2, 3],  
        [4, 5, 6]  
      ]"  
    };  
      
    await client.api('/me/drive/items/{id}/workbook/tables/Table1/rows')  
    	.version('beta')  
    	.post(workbookTableRow);  
    

    You can add rows to the end of a table. Note that this API can accept multiple rows of data. Adding one row at a time can affect performance. The recommended approach is to batch the rows together in a single call rather than inserting single rows.
    Here is the document for more details
    https://learn.microsoft.com/en-us/graph/api/table-post-rows?view=graph-rest-1.0&tabs=http


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.