Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Example of fill bgColor cell in excel4node

I am using excel4node to create Excel file in nodeJS. The site gives following guideline to use fill property.

fill: { // §18.8.20 fill (Fill)
      type: string, // Currently only 'pattern' is implimented. Non-   implimented option is 'gradient'
      patternType: string, //§18.18.55 ST_PatternType (Pattern Type)
      bgColor: string // HTML style hex value. optional. defaults to black
      fgColor: string // HTML style hex value. required.
  },

I could not work around this. Anyone can help me, please?

like image 446
Nizamuddin Shaikh Avatar asked Mar 30 '17 13:03

Nizamuddin Shaikh


People also ask

Does excel4node support conditional formatting?

A subset of conditional formatting features is currently supported by excel4node. Formatting rules apply at the worksheet level. The only conditional formatting type that is currently supported is expression. When the formula returns zero, conditional formatting is NOT displayed.

What is excel4node?

A full featured xlsx file generation library allowing for the creation of advanced Excel files. excel4node conforms to the ECMA-376 OOXML specification 2nd edition An instance of the Workbook class contains all data and parameters for the Excel Workbook. Workbook constructor accepts an optional configuration object.

How does excel4node conform to the OOXML specification?

excel4node conforms to the ECMA-376 OOXML specification 2nd edition An instance of the Workbook class contains all data and parameters for the Excel Workbook.


1 Answers

Basically what you can do with the package in its current state is the following:

fill: {
    type: 'pattern', // the only one implemented so far.
    patternType: 'solid', // most common.
    fgColor: '2172d7', // you can add two extra characters to serve as alpha, i.e. '2172d7aa'.
    // bgColor: 'ffffff' // bgColor only applies on patternTypes other than solid.
}

Note that the background color of your cell will be the foreground color (fgColor) of the fill property. It sounds confusing, but it makes sense when you understand that the fill property have patterns that use more than one color, hence the property having foreground and background colors.

The 'solid' patternType is probably what you're looking for, but there are others, such as 'darkDown', 'darkHorizontal', 'lightGrid', and etc, as can be seen here: excel4node/fillPattern.js

like image 182
Cristhian Bonilha Avatar answered Oct 20 '22 00:10

Cristhian Bonilha