| 20 | |
| 21 | class Worksheet { |
| 22 | constructor(options) { |
| 23 | options = options || {}; |
| 24 | this._workbook = options.workbook; |
| 25 | |
| 26 | // in a workbook, each sheet will have a number |
| 27 | this.id = options.id; |
| 28 | this.orderNo = options.orderNo; |
| 29 | |
| 30 | // and a name |
| 31 | this.name = options.name; |
| 32 | |
| 33 | // add a state |
| 34 | this.state = options.state || 'visible'; |
| 35 | |
| 36 | // rows allows access organised by row. Sparse array of arrays indexed by row-1, col |
| 37 | // Note: _rows is zero based. Must subtract 1 to go from cell.row to index |
| 38 | this._rows = []; |
| 39 | |
| 40 | // column definitions |
| 41 | this._columns = null; |
| 42 | |
| 43 | // column keys (addRow convenience): key ==> this._collumns index |
| 44 | this._keys = {}; |
| 45 | |
| 46 | // keep record of all merges |
| 47 | this._merges = {}; |
| 48 | |
| 49 | // record of all row and column pageBreaks |
| 50 | this.rowBreaks = []; |
| 51 | |
| 52 | // for tabColor, default row height, outline levels, etc |
| 53 | this.properties = Object.assign( |
| 54 | {}, |
| 55 | { |
| 56 | defaultRowHeight: 15, |
| 57 | dyDescent: 55, |
| 58 | outlineLevelCol: 0, |
| 59 | outlineLevelRow: 0, |
| 60 | }, |
| 61 | options.properties |
| 62 | ); |
| 63 | |
| 64 | // for all things printing |
| 65 | this.pageSetup = Object.assign( |
| 66 | {}, |
| 67 | { |
| 68 | margins: {left: 0.7, right: 0.7, top: 0.75, bottom: 0.75, header: 0.3, footer: 0.3}, |
| 69 | orientation: 'portrait', |
| 70 | horizontalDpi: 4294967295, |
| 71 | verticalDpi: 4294967295, |
| 72 | fitToPage: !!( |
| 73 | options.pageSetup && |
| 74 | (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && |
| 75 | !options.pageSetup.scale |
| 76 | ), |
| 77 | pageOrder: 'downThenOver', |
| 78 | blackAndWhite: false, |
| 79 | draft: false, |