-
Notifications
You must be signed in to change notification settings - Fork 2
feat(excel): support excel spreadsheets on sharepoint sites #6
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to use the graph api.
const driveItem = await drive.getDriveItemFromShareLink(url); | ||
const xlsxbuffer = await drive.downloadDriveItem(driveItem); | ||
|
||
const workbook = XLSX.read(xlsxbuffer, { type: 'buffer' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better to use the excel api:
https://docs.microsoft.com/en-us/graph/api/resources/excel?view=graph-rest-1.0
eg: https://docs.microsoft.com/en-us/graph/api/worksheet-get?view=graph-rest-1.0&tabs=http#example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried, but ran into this error: https://stackoverflow.com/questions/50216300/could-not-obtain-wac-access-token
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/excel.test.js
Outdated
const result = await main({ | ||
__ow_path: '/https://adobe.sharepoint.com/sites/TheBlog/_layouts/15/guestaccess.aspx', | ||
share: 'ESR1N29Z7HpCh1Zfs_0YS_gB4gVSuKyWRut-kNcHVSvkew', | ||
email: 'helix%40adobe.com', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is email used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not needed, but part of the share link as you copy it from the UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I said, better provide the entire sharelink as param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it. The entire share link is https://adobe.sharepoint.com/sites/TheBlog/_layouts/15/guestaccess.aspx?share=ESR1N29Z7HpCh1Zfs_0YS_gB4gVSuKyWRut-kNcHVSvkew&email=helix%40adobe.com&e=rcfCT3
This gets appended to the service URL, so that the path is /https://adobe.sharepoint.com/sites/TheBlog/_layouts/15/guestaccess.aspx
and the URL parameters are passed as individual parameters.
If I pass the remaining parameters as __ow_query="share=ESR1N29Z7HpCh1Zfs_0YS_gB4gVSuKyWRut-kNcHVSvkew&email=helix%40adobe.com&e=rcfCT3"
I'm not gaining anything, because I now have to parse the query string – something that only occurs in testing, never in production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my problem is, that your sharelink argument is distributed as path and query params. this is inconsistent and pollutes the action params. I would do:
...data-embed@v1?share=https://adobe.sharepoint.com/sites/TheBlog/_layouts/15/guestaccess.aspx%21share=ESR1N29Z7HpCh1Zfs_0YS_gB4gVSuKyWRut-kNcHVSvkew%22email=helix%40adobe.com%22e=rcfCT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather keep it the way it is, so that helix-embed
and helix-data-embed
have the same API (just append the full URL)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don' think this is good. if the url would be url-encoded, i would be marginally better.
you already see from your code, that you need to reconstruct the share link based on the path and some params...and you always need to rely on the exact format of the link.
what if MS or google decides to add a new query param to the sharelink?
Co-Authored-By: Tobias Bocanegra <tripodsan@users.noreply.github.com>
Co-Authored-By: Tobias Bocanegra <tripodsan@users.noreply.github.com>
This PR will trigger a minor release when merged. |
1 similar comment
This PR will trigger a minor release when merged. |
Co-Authored-By: Tobias Bocanegra <tripodsan@users.noreply.github.com>
This PR will trigger a minor release when merged. |
@tripodsan I'll add Polly and suggest we merge then, as we can iterate on the minor points later. |
This PR will trigger a minor release when merged. |
Codecov Report
@@ Coverage Diff @@
## master #6 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 4 +1
Lines 40 56 +16
=========================================
+ Hits 40 56 +16
Continue to review full report at Codecov.
|
those are not minor points.... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- don't abuse
__ow_path
as document link - use excel graph api
I don't think it's abuse and I don't want to break compatibility with
I really don't see the benefit of using an API that has proven to be brittle when we have a working alternative. In addition, using the graph API would require more extensive mocking that is just adding dead testing code instead of verifying the functionality. |
This PR will trigger a minor release when merged. |
then, I suggest to do it better here and then fix the it causes already problems. you have to admit, that using the path doesn't add benefits and only complicates the parsing. |
why brittle? donwloading the file has drackbacks
|
This PR will trigger a minor release when merged. |
The advantage of the |
This PR will trigger a minor release when merged. |
This PR will trigger a minor release when merged. |
By the way, I find your insistence on using both the Excel Graph API and then mocking it until it doesn't expose the real-world behavior (and issues) anymore quite hard to reconcile. I would (grudgingly) try to port it to the Graph API, but not when it means that the tests that I have are completely useless during development and won't help me troubeshoot issues with the underlying APIs. |
This PR will trigger a minor release when merged. |
IMO, the unit tests should work w/o external infrastructure, especially when it relies on resources on personal shares or repositories, or requires authentication with such. I agree, that mocking the API bears its dangers of not catching changes in that API. the mocking the API tests your code; integration tests test their code.
I agree. So maybe the pollyjs approach is the good inbetween solution? you can disable playback during development and record it then for faster testing? sidenote: |
Please ensure your pull request adheres to the following guidelines:
Related Issues
Thanks for contributing!