-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uploading data into an Excel Spreadsheet. #3036
Comments
what does excel's writeBuffer() produce? |
writeBuffer provides a They seem to use their own type for Buffer that extends ArrayBuffer, there is a stack overflow question talking about how this excelJS.Buffer breaks the excel file. Athough there isnt a set solution that I have tested from this aspect. |
It doesnt look like this solution works in either casting to any or casting to plain JS Buffer. |
_testingExcel = async (): Promise<void> => {
const url =
"______/something.xlsx";
let workbook = new Excel.Workbook();
await this._sp.web
.getFileByServerRelativePath(url)
.getBuffer()
.then((buffer) => {
console.log(buffer); // <-- 1
workbook.xlsx.load(buffer);
console.log(workbook); // <-- 2
});
let excelBuffer = await workbook.xlsx.writeBuffer();
console.log(excelBuffer); // <-- 3
let setContent = await this._sp.web.getFileByServerRelativePath(url).setContent(excelBuffer);
console.log(setContent); // <-- 4
}; |
This seems to be an issue with ExcelJS, I will close this now as this has appeared here. |
This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked. |
What version of PnPjs library you are using
3.x
Minor Version Number
3.19.0
Target environment
All
Additional environment details
Currently performing testing locally on the workbench.
Question/Request
I am currently trying to add data into a sheet. I assumed that the function from
getFileByServerRelativePath()
.This block of code works perfectly fine for reading data but as soon as I try to set the content of a changed worksheet, it changes the MIME-TYPE to "application/zip" and the workbook changes state to a "read-only" mode.
Another part of this error is that the reason Excel gives for being in a read-only mode and "repairing" itself is this AutoFilter table change.
I want to continue to use tables in the excel files that are being edited and removing the tables and reverting them back to their regular ranges removes the issue.
How can I ensure that the mime-type stays the same and that the workbook does not "break" and enter the read-only state?
The text was updated successfully, but these errors were encountered: