最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - Is there a way to open, save and close an excel file (.xlsx)? - Stack Overflow

programmeradmin3浏览0评论

I've got a daily automated function in nodejs which builds and populates an excel spreadsheet via the package xlsx-populate, which has been running for a couple of years now with no problems.

A colleague now wants to connect this file with Power Bi, but an error occurs saying:

The input couldnt be recognised as a valid Excel Document.  

  
DataFormat.Error: The document cannot be opened because there is an invalid part with an unexpected content type.

I believe (from this article here) that it's due to a issue within the xlsx-populate package, not saving xml correctly.

When we open, save and close the excel file (without making any changes), it works perfectly.

Is there a way that my automated function can open, save and close the spreadsheet to avoid the need to manually do this each day? Or perhaps there's another way around the problem which I haven't thought of.

Thanks

I've got a daily automated function in nodejs which builds and populates an excel spreadsheet via the package xlsx-populate, which has been running for a couple of years now with no problems.

A colleague now wants to connect this file with Power Bi, but an error occurs saying:

The input couldnt be recognised as a valid Excel Document.  

  
DataFormat.Error: The document cannot be opened because there is an invalid part with an unexpected content type.

I believe (from this article here) that it's due to a issue within the xlsx-populate package, not saving xml correctly.

When we open, save and close the excel file (without making any changes), it works perfectly.

Is there a way that my automated function can open, save and close the spreadsheet to avoid the need to manually do this each day? Or perhaps there's another way around the problem which I haven't thought of.

Thanks

Share Improve this question asked 2 days ago SosijElizabethSosijElizabeth 973 silver badges17 bronze badges 3
  • 1 Not enough information. Please see: How to create a Minimal, Reproducible Example. – Sergey A Kryukov Commented 2 days ago
  • Do I really need a reproducible example when asking if there is a way to open, close and save a file? – SosijElizabeth Commented 2 days ago
  • 1 Maybe ask @SergeyAKryukov how he would make an example for this. This seems like a niche error that will probably be hard to find a solution. I would compare the XML of the XLXS files before and after opening/saving ("open, save and close...works") to see what's changed and if the populate process can be fixed/changed to do the same. – Hannover Fist Commented 2 days ago
Add a comment  | 

1 Answer 1

Reset to default 0

Assuming you really just want to do what you ask...I don't see the need to tie this into the same programmatic interface, since you're effectively hacking through to a solution anyway. Decouple it from your infrastructure and just use another process script to do the excel open/close. Here is another link to an answer for how to do this, that should guide you: Open, save and close an Excel file from the command prompt without interaction

you could of course call it from this process, or set a scheduler/timer to activate it, and so on. Given the lack of other details, this should answer your question asked.

发布评论

评论列表(0)

  1. 暂无评论