Skip to content
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

can't open xlsx files with password #352

Open
GX158 opened this issue Dec 27, 2022 · 3 comments
Open

can't open xlsx files with password #352

GX158 opened this issue Dec 27, 2022 · 3 comments

Comments

@GX158
Copy link

GX158 commented Dec 27, 2022

when i open the xlsx file ,the system occurs some error like this:

[Running] node "e:\js_project\decipher-excel\test.js"
Error: Non-whitespace before first tag.
Line: 0
Column: 1
Char: �
at error (e:\js_project\decipher-excel\node_modules\sax\lib\sax.js:651:10)
at strictFail (e:\js_project\decipher-excel\node_modules\sax\lib\sax.js:677:7)
at beginWhiteSpace (e:\js_project\decipher-excel\node_modules\sax\lib\sax.js:951:7)
at SAXParser.write (e:\js_project\decipher-excel\node_modules\sax\lib\sax.js:1006:11)
at e:\js_project\decipher-excel\node_modules\xlsx-populate\lib\XmlParser.js:72:20
at new Promise ()
at XmlParser.parseAsync (e:\js_project\decipher-excel\node_modules\xlsx-populate\lib\XmlParser.js:20:16)
at Encryptor._parseEncryptionInfoAsync (e:\js_project\decipher-excel\node_modules\xlsx-populate\lib\Encryptor.js:371:26)
at e:\js_project\decipher-excel\node_modules\xlsx-populate\lib\Encryptor.js:247:30

[Done] exited with code=0 in 0.285 seconds

and this is my code:
`const XlsxPopulate = require("xlsx-populate");

var pa=String.rawE:\js_project\decipher-excel\excel\TEST Passwrod[a-1].xlsx;

async function openExcel(file, password) {
try {
await XlsxPopulate.fromFileAsync(file, { password });
console.log("ok");
return true;
} catch (error) {
console.error(error);
return false;
}
}

openExcel(pa,'1');`

can somebody tell me why?(i will be cry)

@zurmokeeper
Copy link

@GX158 Has this problem been solved? I have this problem now, I remember around 2022-July, I tried to be able to parse the encrypted excel, I don't know why it suddenly doesn't work now, I am using wps to create the excel file with password encryption?

@zurmokeeper
Copy link

@GX158 I tried again, office excel new with password can be decrypted, wps can not. If you use wps to open the new excel file with password created by office excel and then save it, then use xlsx-populate also can not decrypt it, it should be wps to save some content format changes, resulting in xlsx-populate also can not be decrypted

@zurmokeeper
Copy link

@GX158 You can try @zurmokeeper/exceljs https://www.npmjs.com/package/@zurmokeeper/exceljs

// read from a file, decrypt excel files encrypted with password
const workbook = new Excel.Workbook();
await workbook.xlsx.readFile(filename, {password:'123456'});
// ... use workbook

xlsx-populate only supports ecma376 agile encrytion, not ecma376 standard encrytion, this library supports both encryption methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants