Package detail

sheetjs-style

ShanaMaid103.7kApache-2.00.15.8

SheetJS Spreadsheet data parser and writer

excel, xls, xlsx, xlsb

readme

Sheetjs-style

travis ci badge version license downloads downloads-month

support set cell style for sheetjs!

API is the same as sheetjs!

install

npm install sheetjs-style

How to Use?

Please read SheetJs Documents!

How to set cell Style?

for example:

ws["A1"].s = {                                    // set the style for target cell
  font: {
    name: '宋体',
    sz: 24,
    bold: true,
    color: { rgb: "FFFFAA00" }
  },
};

单元格设置样式

Cell Styles

Cell styles are specified by a style object that roughly parallels the OpenXML structure. The style object has five top-level attributes: fill, font, numFmt, alignment, and border.

Style Attribute Sub Attributes Values
fill patternType "solid" or "none"
fgColor COLOR_SPEC
bgColor COLOR_SPEC
font name "Calibri" // default
sz "11" // font size in points
color COLOR_SPEC
bold true or false
underline true or false
italic true or false
strike true or false
outline true or false
shadow true or false
vertAlign true or false
numFmt "0" // integer index to built in formats, see StyleBuilder.SSF property
"0.00%" // string matching a built-in format, see StyleBuilder.SSF
"0.0%" // string specifying a custom format
"0.00%;\\(0.00%\\);\\-;@" // string specifying a custom format, escaping special characters
"m/dd/yy" // string a date format using Excel's format notation
alignment vertical "bottom" or "center" or "top"
horizontal "left" or "center" or "right"
wrapText true or false
readingOrder 2 // for right-to-left
textRotation Number from 0 to 180 or 255 (default is 0)
90 is rotated up 90 degrees
45 is rotated up 45 degrees
135 is rotated down 45 degrees
180 is rotated down 180 degrees
255 is special, aligned vertically
border top { style: BORDER_STYLE, color: COLOR_SPEC }
bottom { style: BORDER_STYLE, color: COLOR_SPEC }
left { style: BORDER_STYLE, color: COLOR_SPEC }
right { style: BORDER_STYLE, color: COLOR_SPEC }
diagonal { style: BORDER_STYLE, color: COLOR_SPEC }
diagonalUp true or false
diagonalDown true or false

COLOR_SPEC: Colors for fill, font, and border are specified as objects, either:

  • { auto: 1} specifying automatic values
  • { rgb: "FFFFAA00" } specifying a hex ARGB value
  • { theme: "1", tint: "-0.25"} specifying an integer index to a theme color and a tint value (default 0)
  • { indexed: 64} default value for fill.bgColor

BORDER_STYLE: Border style is a string value which may take on one of the following values:

  • thin
  • medium
  • thick
  • dotted
  • hair
  • dashed
  • mediumDashed
  • dashDot
  • mediumDashDot
  • dashDotDot
  • mediumDashDotDot
  • slantDashDot

Borders for merged areas are specified for each cell within the merged area. So to apply a box border to a merged area of 3x3 cells, border styles would need to be specified for eight different cells:

  • left borders for the three cells on the left,
  • right borders for the cells on the right
  • top borders for the cells on the top
  • bottom borders for the cells on the left

Thanks

sheetjs js-xlsx

changelog

CHANGELOG

This log is intended to keep track of backwards-incompatible changes, including but not limited to API changes and file location changes. Minor behavioral changes may not be included if they are not expected to break existing code.

v0.15.6

  • CFB prevent infinite loop
  • ODS empty cells marked as stub (type "z")
  • cellStyles option implies sheetStubs

v0.15.5

  • sheets parse option to specify which sheets to parse

v0.15.4

  • AOA utilities properly preserve number formats
  • Number formats captured in stub cells

v0.15.3

  • Properties and Custom Properties properly XML-encoded

v0.15.2

  • sheet_get_cell utility function
  • sheet_to_json explicitly support null as alias for default behavior
  • encode_col throw on negative column index
  • HTML properly handle whitespace around tags in a run
  • HTML use id option on write
  • Files starting with 0x09 followed by a display character are now TSV files
  • XLS parse references col/row indices mod by the correct number for BIFF ver
  • XLSX comments moved to avoid overlapping cell
  • XLSB outline level
  • AutoFilter update _FilterDatabase defined name on write
  • XLML skip CDATA blocks

v0.15.1 (2019-08-14)

  • XLSX ignore XML artifacts
  • HTML capture and persist merges

v0.15.0

  • dist/xlsx.mini.min.js mini build with XLSX read/write and some utilities
  • Removed legacy conversion utility functions

v0.14.5

  • XLS PtgNameX lookup
  • XLS always create stub cells for blank cells with comments

v0.14.4

  • Better treatment of skipHidden in CSV output
  • Ignore CLSID in XLS
  • SYLK 7-bit character encoding
  • SYLK and DBF codepage support

v0.14.3

  • Proper shifting of addresses in Shared Formulae

v0.14.2

  • Proper XML encoding of comments

v0.14.1

  • raw cell objects can be passed to sheet_add_aoa
  • _FilterDatabase fix for AutoFilter-related crashes
  • stream.to_json doesn't end up accidentally scanning to max row

0.14.0 (2018-09-06)

  • sheet_to_json default flipped to raw: true

0.13.5 (2018-08-25)

  • HTML output generates <br/> instead of encoded newline character

0.13.2 (2018-07-08)

  • Buffer.from shim replaced, will not be defined in node <=0.12

0.13.0 (2018-06-01)

  • Library reshaped to support AMD out of the box

0.12.11 (2018-04-27)

  • XLS/XLSX/XLSB range truncation (errors in WTF mode)

0.12.4 (2018-03-04)

  • JSZip renamed to JSZipSync

0.12.0 (2018-02-08)

  • Extendscript target script in NPM package

0.11.19 (2018-02-03)

  • Error on empty workbook

0.11.16 (2017-12-30)

  • XLS ANSI/CP separation
  • 'array' write type and ArrayBuffer processing

0.11.6 (2017-10-16)

  • Semicolon-delimited files are detected

0.11.5 (2017-09-30)

  • Bower main script shifted to full version
  • 'binary' / 'string' encoding

0.11.3 (2017-08-19)

  • XLS cell ixfe/XF removed

0.11.0 (2017-07-31)

  • Strip require statements from minified version
  • minifier mangler enabled

0.10.9 (2017-07-28)

  • XLML/HTML resolution logic looks further into the data stream to decide type
  • Errors thrown on suspected RTF files

0.10.5 (2017-06-09)

  • HTML Table output header/footer should not include <table> tag

0.10.2 (2017-05-16)

  • Dates are converted to numbers by default (set cellDates:true to emit Dates)
  • Module does not export CFB

0.9.10 (2017-04-08)

  • --perf renamed to --read-only

0.9.9 (2017-04-03)

  • default output format changed to XLSB
  • comment text line endings are now normalized
  • errors thrown on write when worksheets have invalid names

0.9.7 (2017-03-28)

  • XLS legacy !range field removed
  • Hyperlink tooltip is stored in the Tooltip field

0.9.6 (2017-03-25)

  • sheet_to_json now passes null values when raw is set to true
  • sheet_to_json treats null stub cells as values in conjunction with raw

0.9.5 (2017-03-22)

  • cellDates affects parsing in non-XLSX formats

0.9.3 (2017-03-15)

  • XLML property names are more closely mapped to the XLSX equivalent
  • Stub cells are now cell type z

0.9.2 (2017-03-13)

  • Removed stale TypeScript definition files. Flowtype comments are used in the xlsx.flow.js source and stripped to produce xlsx.js.
  • sed usage reworked to support GNU sed in-place form. BSD sed seems to work, but the build script has not been tested on other sed variants:
$ sed -i.ext  [...] # GNU
$ sed -i .ext [...] # bsd

0.9.0 (2017-03-09)

  • Removed ods.js source. The xlsx.js source absorbed the ODS logic and exposes the ODS variable, so projects should remove references to ods.js