问题
I am trying to read the contents of excel and write it into another excel. But may be i am missing something. here is relevant part of my code
await fetch(fetchUrl)
.then(
res =>
new Promise((resolve, reject) => {
const dest = fs.createWriteStream("./text.xlsx");
res.body.pipe(dest);
res.body.on("end", () => resolve("it worked"));
dest.on("error", reject);
})
)
.then(x => console.log(x));
I get the following alert if i try to open the file
Excel cannot open the file ’text.xlsx’ because the file format or file extension is not valid. Verify
that the file has not been corrupted and that the file extension matches the format of the file.
Any help as to what i am missing will be really great. Thanks.
来源:https://stackoverflow.com/questions/65254633/node-js-fetch-pipe-with-excel-not-working