werkmap 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -88,7 +88,7 @@ werkmap writes the slice of the format a report needs, and refuses the rest.
88
88
  **It does not fit when:**
89
89
 
90
90
  - You need to read, edit or convert an existing workbook.
91
- - You need formulas, charts, pivot tables, conditional formatting, data validation, hyperlinks, comments or sheet protection.
91
+ - You need formulas, charts, pivot tables, conditional formatting, data validation, hyperlinks, comments, sheet protection, or a page header and footer.
92
92
  - You need column widths or row heights. A reader sizes columns from its own defaults.
93
93
  - You have more rows than fit in memory. There is no streaming, row-at-a-time output.
94
94
 
@@ -141,6 +141,14 @@ One merged range across `width` columns of `row`, starting at the 1-based column
141
141
 
142
142
  Freeze the top `rows` rows. `0` clears.
143
143
 
144
+ ### `sheet.print(setup)`
145
+
146
+ How this worksheet prints: `{ margin, size, orientation, fit, titles }`, every key optional. `margin` is all four page margins in points, `size` one of `letter`, `tabloid`, `legal`, `A3`, `A4`, `A5`, `orientation` either `portrait` or `landscape`, and `fit: true` scales the sheet to one page wide and as many pages tall as it takes.
147
+
148
+ A worksheet that never calls this carries **no print setup at all**, so a reader applies its own defaults rather than this writer's opinion. Calls merge, so two calls naming different keys both take effect. Print setup is per worksheet, which is where OOXML puts it.
149
+
150
+ `titles: n` repeats the top `n` rows at the top of every printed page — the paper counterpart of `freeze`, which keeps them in view on screen. `0` clears it, as it does for a freeze. This one is written as a `_xlnm.Print_Titles` defined name in `xl/workbook.xml` rather than in the sheet part, and it is scoped to this worksheet alone, so each sheet of a workbook repeats its own rows.
151
+
144
152
  ### `sheet.place(id, { row, col, width, height })`
145
153
 
146
154
  One floating picture anchored to the top-left of a 1-based cell, drawn at `width` × `height` CSS pixels at 96 dpi.
@@ -173,7 +181,7 @@ There is nothing to configure. Each of these is a property of the writer rather
173
181
 
174
182
  - **Text is always interned** into the shared string table.
175
183
  - **Style tables are always interned.**
176
- - **Dates are the 1900 system**, converted in UTC. A reader's timezone is never consulted, and the phantom 1900-02-29 is accounted for, so a date before March 1900 lands on the day it names.
184
+ - **Dates are the 1900 system**, converted in UTC. A reader's timezone never enters the conversion. This writer counts Excel's phantom 1900-02-29, so a date before March 1900 lands on the day it names in Excel. ECMA-376 defines the 1900 system with that fictitious day. LibreOffice Calc omits it and shows those dates one day early. No single serial satisfies both readers, so this writer follows the specification. A date from 1900-03-01 on reads the same in both, which covers every date a report is likely to hold.
177
185
  - **A date with no format of its own** gets the short-date built-in, so it reads back as a day rather than as the number underneath it.
178
186
  - **Media deduplicates by bytes.**
179
187
  - **Every element is written in the Open XML SDK's child order.**
package/lib/index.d.ts CHANGED
@@ -75,6 +75,22 @@ export interface Placement {
75
75
  height: number;
76
76
  }
77
77
 
78
+ /** How a worksheet prints. Every key is optional. */
79
+ export interface PrintSetup {
80
+ /** All four page margins, in points. Defaults to the reader's own. */
81
+ margin?: number;
82
+ /** A paper size OOXML names. There is no arbitrary width and height. */
83
+ size?: "letter" | "tabloid" | "legal" | "A3" | "A4" | "A5";
84
+ orientation?: "portrait" | "landscape";
85
+ /** Scale the sheet to one page wide, and as many pages tall as it takes. */
86
+ fit?: boolean;
87
+ /**
88
+ * Repeat the top `rows` rows at the top of every printed page. `0` clears,
89
+ * the way a `freeze` of `0` does. Scoped to this worksheet alone.
90
+ */
91
+ titles?: number;
92
+ }
93
+
78
94
  export interface Sheet {
79
95
  /** This sheet's name. */
80
96
  readonly name: string;
@@ -90,6 +106,12 @@ export interface Sheet {
90
106
  merge(row: number, at: number, width: number): void;
91
107
  /** Freeze the top `count` rows. `0` clears. */
92
108
  freeze(count: number): void;
109
+ /**
110
+ * How this worksheet prints. A worksheet that never calls this carries no
111
+ * print setup at all, so a reader applies its own defaults. Calls merge, so
112
+ * two calls naming different keys both take effect.
113
+ */
114
+ print(setup: PrintSetup): void;
93
115
  /** Float a picture over the sheet, anchored to one cell. */
94
116
  place(id: number, at: Placement): void;
95
117
  }