protobi / js-xlsx

XLSX / XLSM / XLSB (Excel 2007+ Spreadsheet) / ODS parser and writer
http://oss.sheetjs.com/js-xlsx
Other
814 stars 416 forks source link

How to style first row? #164

Open matze1708 opened 2 years ago

matze1708 commented 2 years ago

Hi guys,

how it is possible to style the first row?

i´d try this

          const CellOptions = {
            font: {
              name: 'Arial',
              sz: 10,
              bold: true,
              color: { rgb: "FFFFFFFF" }
            },
            fill: {
              bgColor: { rgb: "FF59AB44" },
              fgColor: { rgb: "FF59AB44" },
            },
            alignment: {
              wrapText: true
            },
          };

      WS['A1'].s = CellOptions;

but what i do for A1 i need A1 to K1

Thanks you

pietersv commented 2 years ago

If you know the extent, you can iterate over each cell, e.g. "ABCDEFGHIJK".split('').forEach(c=>WS[c+'1'].s = CellOptions)