How to use xlsx to set the style of the exported table in Node.js?

I have seen a lot of examples, all of which are used to set

in the following way.
cell.s = {
       font: { color: { rgb: "ffff00" } },
       fill: { bgColor: { rgb: "ffff00" } }
}

I tried and found that it didn"t work, but the style worked when I replaced the xlsx package with xlsx-style (all the previously exported data has been written the same).

I want to know why it doesn"t work with the xlsx package, is it that the package itself doesn"t support it, or is it that there"s something wrong with my writing? Hope God"s advice!

Jun.07,2021

I have looked at the source code of xlsx and xlsx-style libraries these days and found that xlsx does not seem to have a parsing style module, so it is invalid when you use attributes like s.font.color. On the other hand, xlsx-style, adds the module of style parsing.

clipboard.png

if you read an extra styleBuild, xlsx-style will be able to parse the style.

but after using xlsx-style, your row height must not be set. I have messed up a solution by myself, which you can refer to.

use xlsx-style to set the width and height style of the table:
https://www.jianshu.com/p/877.


how to play automatic line wrapping? I did not find the js-xlsx-related


xlsx-style style cannot set line height. I opened a branch and directly fixed it. Ok
you can directly use: npm install just2lab-xlsx-style-- save
source address: https://github.com/justinbett.

Menu