1 | /* index.d.ts (C) 2015-present SheetJS and contributors */
|
2 | // TypeScript Version: 2.2
|
3 | // import * as CFB from "cfb";
|
4 | // import * as SSF from "ssf";
|
5 |
|
6 | /** Version string */
|
7 | export const version: string;
|
8 |
|
9 | /** SSF Formatter Library */
|
10 | // export { SSF };
|
11 | export const SSF: any;
|
12 |
|
13 | /** CFB Library */
|
14 | // export { CFB };
|
15 | export const CFB: any;
|
16 |
|
17 | /** ESM ONLY! Set internal `fs` instance */
|
18 | export function set_fs(fs: any): void;
|
19 | /** ESM ONLY! Set internal codepage tables */
|
20 | export function set_cptable(cptable: any): void;
|
21 |
|
22 | /** NODE ONLY! Attempts to read filename and parse */
|
23 | export function readFile(filename: string, opts?: ParsingOptions): WorkBook;
|
24 | /** Attempts to parse data */
|
25 | export function read(data: any, opts?: ParsingOptions): WorkBook;
|
26 | /** Attempts to write or download workbook data to file */
|
27 | export function writeFile(data: WorkBook, filename: string, opts?: WritingOptions): any;
|
28 | /** Attempts to write or download workbook data to XLSX file */
|
29 | export function writeFileXLSX(data: WorkBook, filename: string, opts?: WritingOptions): any;
|
30 | /** Attempts to write or download workbook data to file asynchronously */
|
31 | type CBFunc = () => void;
|
32 | export function writeFileAsync(filename: string, data: WorkBook, opts: WritingOptions | CBFunc, cb?: CBFunc): any;
|
33 | /** Attempts to write the workbook data */
|
34 | export function write(data: WorkBook, opts: WritingOptions): any;
|
35 | /** Attempts to write the workbook data as XLSX */
|
36 | export function writeXLSX(data: WorkBook, opts: WritingOptions): any;
|
37 |
|
38 | /** Utility Functions */
|
39 | export const utils: XLSX$Utils;
|
40 | /** Stream Utility Functions */
|
41 | export const stream: StreamUtils;
|
42 |
|
43 | /** Number Format (either a string or an index to the format table) */
|
44 | export type NumberFormat = string | number;
|
45 |
|
46 | /** Worksheet specifier (string, number, worksheet) */
|
47 | export type WSSpec = string | number | WorkSheet;
|
48 |
|
49 | /** Range specifier (string or range or cell), single-cell lifted to range */
|
50 | export type RangeSpec = string | Range | CellAddress;
|
51 |
|
52 | /** Basic File Properties */
|
53 | export interface Properties {
|
54 | /** Summary tab "Title" */
|
55 | Title?: string;
|
56 | /** Summary tab "Subject" */
|
57 | Subject?: string;
|
58 | /** Summary tab "Author" */
|
59 | Author?: string;
|
60 | /** Summary tab "Manager" */
|
61 | Manager?: string;
|
62 | /** Summary tab "Company" */
|
63 | Company?: string;
|
64 | /** Summary tab "Category" */
|
65 | Category?: string;
|
66 | /** Summary tab "Keywords" */
|
67 | Keywords?: string;
|
68 | /** Summary tab "Comments" */
|
69 | Comments?: string;
|
70 | /** Statistics tab "Last saved by" */
|
71 | LastAuthor?: string;
|
72 | /** Statistics tab "Created" */
|
73 | CreatedDate?: Date;
|
74 | }
|
75 |
|
76 | /** Other supported properties */
|
77 | export interface FullProperties extends Properties {
|
78 | ModifiedDate?: Date;
|
79 | Application?: string;
|
80 | AppVersion?: string;
|
81 | DocSecurity?: string;
|
82 | HyperlinksChanged?: boolean;
|
83 | SharedDoc?: boolean;
|
84 | LinksUpToDate?: boolean;
|
85 | ScaleCrop?: boolean;
|
86 | Worksheets?: number;
|
87 | SheetNames?: string[];
|
88 | ContentStatus?: string;
|
89 | LastPrinted?: string;
|
90 | Revision?: string | number;
|
91 | Version?: string;
|
92 | Identifier?: string;
|
93 | Language?: string;
|
94 | }
|
95 |
|
96 | export interface CommonOptions {
|
97 | /**
|
98 | * If true, throw errors when features are not understood
|
99 | * @default false
|
100 | */
|
101 | WTF?: boolean;
|
102 |
|
103 | /**
|
104 | * When reading a file with VBA macros, expose CFB blob to `vbaraw` field
|
105 | * When writing BIFF8/XLSB/XLSM, reseat `vbaraw` and export to file
|
106 | * @default false
|
107 | */
|
108 | bookVBA?: boolean;
|
109 |
|
110 | /**
|
111 | * When reading a file, store dates as type d (default is n)
|
112 | * When writing XLSX/XLSM file, use native date (default uses date codes)
|
113 | * @default false
|
114 | */
|
115 | cellDates?: boolean;
|
116 |
|
117 | /**
|
118 | * Create cell objects for stub cells
|
119 | * @default false
|
120 | */
|
121 | sheetStubs?: boolean;
|
122 |
|
123 | /**
|
124 | * When reading a file, save style/theme info to the .s field
|
125 | * When writing a file, export style/theme info
|
126 | * @default false
|
127 | */
|
128 | cellStyles?: boolean;
|
129 |
|
130 | /**
|
131 | * If defined and file is encrypted, use password
|
132 | * @default ''
|
133 | */
|
134 | password?: string;
|
135 | }
|
136 |
|
137 | export interface DateNFOption {
|
138 | /** Use specified date format */
|
139 | dateNF?: NumberFormat;
|
140 | }
|
141 |
|
142 | /** Options for read and readFile */
|
143 | export interface ParsingOptions extends CommonOptions {
|
144 | /** Input data encoding */
|
145 | type?: 'base64' | 'binary' | 'buffer' | 'file' | 'array' | 'string';
|
146 |
|
147 | /** Default codepage */
|
148 | codepage?: number;
|
149 |
|
150 | /**
|
151 | * Save formulae to the .f field
|
152 | * @default true
|
153 | */
|
154 | cellFormula?: boolean;
|
155 |
|
156 | /**
|
157 | * Parse rich text and save HTML to the .h field
|
158 | * @default true
|
159 | */
|
160 | cellHTML?: boolean;
|
161 |
|
162 | /**
|
163 | * Save number format string to the .z field
|
164 | * @default false
|
165 | */
|
166 | cellNF?: boolean;
|
167 |
|
168 | /**
|
169 | * Generate formatted text to the .w field
|
170 | * @default true
|
171 | */
|
172 | cellText?: boolean;
|
173 |
|
174 | /** Override default date format (code 14) */
|
175 | dateNF?: string;
|
176 |
|
177 | /** Field Separator ("Delimiter" override) */
|
178 | FS?: string;
|
179 |
|
180 | /**
|
181 | * If >0, read the first sheetRows rows
|
182 | * @default 0
|
183 | */
|
184 | sheetRows?: number;
|
185 |
|
186 | /**
|
187 | * If true, parse calculation chains
|
188 | * @default false
|
189 | */
|
190 | bookDeps?: boolean;
|
191 |
|
192 | /**
|
193 | * If true, add raw files to book object
|
194 | * @default false
|
195 | */
|
196 | bookFiles?: boolean;
|
197 |
|
198 | /**
|
199 | * If true, only parse enough to get book metadata
|
200 | * @default false
|
201 | */
|
202 | bookProps?: boolean;
|
203 |
|
204 | /**
|
205 | * If true, only parse enough to get the sheet names
|
206 | * @default false
|
207 | */
|
208 | bookSheets?: boolean;
|
209 |
|
210 | /** If specified, only parse the specified sheets or sheet names */
|
211 | sheets?: number | string | Array<number | string>;
|
212 |
|
213 | /** If true, plaintext parsing will not parse values */
|
214 | raw?: boolean;
|
215 |
|
216 | /** If true, preserve _xlfn. prefixes in formula function names */
|
217 | xlfn?: boolean;
|
218 |
|
219 | dense?: boolean;
|
220 |
|
221 | PRN?: boolean;
|
222 | }
|
223 |
|
224 | export interface SheetOption {
|
225 | /**
|
226 | * Name of Worksheet (for single-sheet formats)
|
227 | * @default ''
|
228 | */
|
229 | sheet?: string;
|
230 | }
|
231 |
|
232 | /** Options for write and writeFile */
|
233 | export interface WritingOptions extends CommonOptions, SheetOption {
|
234 | /** Output data encoding */
|
235 | type?: 'base64' | 'binary' | 'buffer' | 'file' | 'array' | 'string';
|
236 |
|
237 | /**
|
238 | * Generate Shared String Table
|
239 | * @default false
|
240 | */
|
241 | bookSST?: boolean;
|
242 |
|
243 | /**
|
244 | * File format of generated workbook
|
245 | * @default 'xlsx'
|
246 | */
|
247 | bookType?: BookType;
|
248 |
|
249 | /**
|
250 | * Use ZIP compression for ZIP-based formats
|
251 | * @default false
|
252 | */
|
253 | compression?: boolean;
|
254 |
|
255 | /**
|
256 | * Suppress "number stored as text" errors in generated files
|
257 | * @default true
|
258 | */
|
259 | ignoreEC?: boolean;
|
260 |
|
261 | /** Override workbook properties on save */
|
262 | Props?: Properties;
|
263 |
|
264 | /** Base64 encoding of NUMBERS base for exports */
|
265 | numbers?: string;
|
266 | }
|
267 |
|
268 | /** Workbook Object */
|
269 | export interface WorkBook {
|
270 | /**
|
271 | * A dictionary of the worksheets in the workbook.
|
272 | * Use SheetNames to reference these.
|
273 | */
|
274 | Sheets: { [sheet: string]: WorkSheet };
|
275 |
|
276 | /** Ordered list of the sheet names in the workbook */
|
277 | SheetNames: string[];
|
278 |
|
279 | /** Standard workbook Properties */
|
280 | Props?: FullProperties;
|
281 |
|
282 | /** Custom workbook Properties */
|
283 | Custprops?: object;
|
284 |
|
285 | Workbook?: WBProps;
|
286 |
|
287 | vbaraw?: any;
|
288 | }
|
289 |
|
290 | export interface SheetProps {
|
291 | /** Name of Sheet */
|
292 | name?: string;
|
293 |
|
294 | /** Sheet Visibility (0=Visible 1=Hidden 2=VeryHidden) */
|
295 | Hidden?: 0 | 1 | 2;
|
296 |
|
297 | /** Name of Document Module in associated VBA Project */
|
298 | CodeName?: string;
|
299 | }
|
300 |
|
301 | /** Defined Name Object */
|
302 | export interface DefinedName {
|
303 | /** Name */
|
304 | Name: string;
|
305 |
|
306 | /** Reference */
|
307 | Ref: string;
|
308 |
|
309 | /** Scope (undefined for workbook scope) */
|
310 | Sheet?: number;
|
311 |
|
312 | /** Name comment */
|
313 | Comment?: string;
|
314 | }
|
315 |
|
316 | /** Workbook-Level Attributes */
|
317 | export interface WBProps {
|
318 | /** Sheet Properties */
|
319 | Sheets?: SheetProps[];
|
320 |
|
321 | /** Defined Names */
|
322 | Names?: DefinedName[];
|
323 |
|
324 | /** Workbook Views */
|
325 | Views?: WBView[];
|
326 |
|
327 | /** Other Workbook Properties */
|
328 | WBProps?: WorkbookProperties;
|
329 | }
|
330 |
|
331 | /** Workbook View */
|
332 | export interface WBView {
|
333 | /** Right-to-left mode */
|
334 | RTL?: boolean;
|
335 | }
|
336 |
|
337 | /** Other Workbook Properties */
|
338 | export interface WorkbookProperties {
|
339 | /** Worksheet Epoch (1904 if true, 1900 if false) */
|
340 | date1904?: boolean;
|
341 |
|
342 | /** Warn or strip personally identifying info on save */
|
343 | filterPrivacy?: boolean;
|
344 |
|
345 | /** Name of Document Module in associated VBA Project */
|
346 | CodeName?: string;
|
347 | }
|
348 |
|
349 | /** DBF Field Header */
|
350 | export interface DBFField {
|
351 | /** Original Field Name */
|
352 | name?: string;
|
353 |
|
354 | /** Field Type */
|
355 | type?: string;
|
356 |
|
357 | /** Field Length */
|
358 | len?: number;
|
359 |
|
360 | /** Field Decimal Count */
|
361 | dec?: number;
|
362 | }
|
363 |
|
364 | /** Column Properties Object */
|
365 | export interface ColInfo {
|
366 | /* --- visibility --- */
|
367 |
|
368 | /** if true, the column is hidden */
|
369 | hidden?: boolean;
|
370 |
|
371 | /* --- column width --- */
|
372 |
|
373 | /** width in Excel's "Max Digit Width", width*256 is integral */
|
374 | width?: number;
|
375 |
|
376 | /** width in screen pixels */
|
377 | wpx?: number;
|
378 |
|
379 | /** width in "characters" */
|
380 | wch?: number;
|
381 |
|
382 | /** outline / group level */
|
383 | level?: number;
|
384 |
|
385 | /** Excel's "Max Digit Width" unit, always integral */
|
386 | MDW?: number;
|
387 |
|
388 | /** DBF Field Header */
|
389 | DBF?: DBFField;
|
390 | }
|
391 |
|
392 | /** Row Properties Object */
|
393 | export interface RowInfo {
|
394 | /* --- visibility --- */
|
395 |
|
396 | /** if true, the column is hidden */
|
397 | hidden?: boolean;
|
398 |
|
399 | /* --- row height --- */
|
400 |
|
401 | /** height in screen pixels */
|
402 | hpx?: number;
|
403 |
|
404 | /** height in points */
|
405 | hpt?: number;
|
406 |
|
407 | /** outline / group level */
|
408 | level?: number;
|
409 | }
|
410 |
|
411 | /**
|
412 | * Write sheet protection properties.
|
413 | */
|
414 | export interface ProtectInfo {
|
415 | /**
|
416 | * The password for formats that support password-protected sheets
|
417 | * (XLSX/XLSB/XLS). The writer uses the XOR obfuscation method.
|
418 | */
|
419 | password?: string;
|
420 | /**
|
421 | * Select locked cells
|
422 | * @default: true
|
423 | */
|
424 | selectLockedCells?: boolean;
|
425 | /**
|
426 | * Select unlocked cells
|
427 | * @default: true
|
428 | */
|
429 | selectUnlockedCells?: boolean;
|
430 | /**
|
431 | * Format cells
|
432 | * @default: false
|
433 | */
|
434 | formatCells?: boolean;
|
435 | /**
|
436 | * Format columns
|
437 | * @default: false
|
438 | */
|
439 | formatColumns?: boolean;
|
440 | /**
|
441 | * Format rows
|
442 | * @default: false
|
443 | */
|
444 | formatRows?: boolean;
|
445 | /**
|
446 | * Insert columns
|
447 | * @default: false
|
448 | */
|
449 | insertColumns?: boolean;
|
450 | /**
|
451 | * Insert rows
|
452 | * @default: false
|
453 | */
|
454 | insertRows?: boolean;
|
455 | /**
|
456 | * Insert hyperlinks
|
457 | * @default: false
|
458 | */
|
459 | insertHyperlinks?: boolean;
|
460 | /**
|
461 | * Delete columns
|
462 | * @default: false
|
463 | */
|
464 | deleteColumns?: boolean;
|
465 | /**
|
466 | * Delete rows
|
467 | * @default: false
|
468 | */
|
469 | deleteRows?: boolean;
|
470 | /**
|
471 | * Sort
|
472 | * @default: false
|
473 | */
|
474 | sort?: boolean;
|
475 | /**
|
476 | * Filter
|
477 | * @default: false
|
478 | */
|
479 | autoFilter?: boolean;
|
480 | /**
|
481 | * Use PivotTable reports
|
482 | * @default: false
|
483 | */
|
484 | pivotTables?: boolean;
|
485 | /**
|
486 | * Edit objects
|
487 | * @default: true
|
488 | */
|
489 | objects?: boolean;
|
490 | /**
|
491 | * Edit scenarios
|
492 | * @default: true
|
493 | */
|
494 | scenarios?: boolean;
|
495 | }
|
496 |
|
497 | /** Page Margins -- see Excel Page Setup .. Margins diagram for explanation */
|
498 | export interface MarginInfo {
|
499 | /** Left side margin (inches) */
|
500 | left?: number;
|
501 | /** Right side margin (inches) */
|
502 | right?: number;
|
503 | /** Top side margin (inches) */
|
504 | top?: number;
|
505 | /** Bottom side margin (inches) */
|
506 | bottom?: number;
|
507 | /** Header top margin (inches) */
|
508 | header?: number;
|
509 | /** Footer bottom height (inches) */
|
510 | footer?: number;
|
511 | }
|
512 | export type SheetType = 'sheet' | 'chart';
|
513 | export type SheetKeys = string | MarginInfo | SheetType;
|
514 | /** General object representing a Sheet (worksheet or chartsheet) */
|
515 | export interface Sheet {
|
516 | /**
|
517 | * Indexing with a cell address string maps to a cell object
|
518 | * Special keys start with '!'
|
519 | */
|
520 | [cell: string]: CellObject | SheetKeys | any;
|
521 |
|
522 | /** Sheet type */
|
523 | '!type'?: SheetType;
|
524 |
|
525 | /** Sheet Range */
|
526 | '!ref'?: string;
|
527 |
|
528 | /** Page Margins */
|
529 | '!margins'?: MarginInfo;
|
530 | }
|
531 |
|
532 | /** AutoFilter properties */
|
533 | export interface AutoFilterInfo {
|
534 | /** Range of the AutoFilter table */
|
535 | ref: string;
|
536 | }
|
537 |
|
538 | export type WSKeys = SheetKeys | ColInfo[] | RowInfo[] | Range[] | ProtectInfo | AutoFilterInfo;
|
539 |
|
540 | /** Worksheet Object */
|
541 | export interface WorkSheet extends Sheet {
|
542 | /**
|
543 | * Indexing with a cell address string maps to a cell object
|
544 | * Special keys start with '!'
|
545 | */
|
546 | [cell: string]: CellObject | WSKeys | any;
|
547 |
|
548 | /** Column Info */
|
549 | '!cols'?: ColInfo[];
|
550 |
|
551 | /** Row Info */
|
552 | '!rows'?: RowInfo[];
|
553 |
|
554 | /** Merge Ranges */
|
555 | '!merges'?: Range[];
|
556 |
|
557 | /** Worksheet Protection info */
|
558 | '!protect'?: ProtectInfo;
|
559 |
|
560 | /** AutoFilter info */
|
561 | '!autofilter'?: AutoFilterInfo;
|
562 | }
|
563 |
|
564 | /**
|
565 | * Worksheet Object with CellObject type
|
566 | *
|
567 | * The normal Worksheet type uses indexer of type `any` -- this enforces CellObject
|
568 | */
|
569 | export interface StrictWS { [addr: string]: CellObject; }
|
570 |
|
571 | /**
|
572 | * The Excel data type for a cell.
|
573 | * b Boolean, n Number, e error, s String, d Date, z Stub
|
574 | */
|
575 | export type ExcelDataType = 'b' | 'n' | 'e' | 's' | 'd' | 'z';
|
576 |
|
577 | /**
|
578 | * Type of generated workbook
|
579 | * @default 'xlsx'
|
580 | */
|
581 | export type BookType = 'xlsx' | 'xlsm' | 'xlsb' | 'xls' | 'xla' | 'biff8' | 'biff5' | 'biff2' | 'xlml' | 'ods' | 'fods' | 'csv' | 'txt' | 'sylk' | 'slk' | 'html' | 'dif' | 'rtf' | 'prn' | 'eth' | 'dbf';
|
582 |
|
583 | /** Comment element */
|
584 | export interface Comment {
|
585 | /** Author of the comment block */
|
586 | a?: string;
|
587 |
|
588 | /** Plaintext of the comment */
|
589 | t: string;
|
590 |
|
591 | /** If true, mark the comment as a part of a thread */
|
592 | T?: boolean;
|
593 | }
|
594 |
|
595 | /** Cell comments */
|
596 | export interface Comments extends Array<Comment> {
|
597 | /** Hide comment by default */
|
598 | hidden?: boolean;
|
599 | }
|
600 |
|
601 | /** Link object */
|
602 | export interface Hyperlink {
|
603 | /** Target of the link (HREF) */
|
604 | Target: string;
|
605 |
|
606 | /** Plaintext tooltip to display when mouse is over cell */
|
607 | Tooltip?: string;
|
608 | }
|
609 |
|
610 | /** Worksheet Cell Object */
|
611 | export interface CellObject {
|
612 | /** The raw value of the cell. Can be omitted if a formula is specified */
|
613 | v?: string | number | boolean | Date;
|
614 |
|
615 | /** Formatted text (if applicable) */
|
616 | w?: string;
|
617 |
|
618 | /**
|
619 | * The Excel Data Type of the cell.
|
620 | * b Boolean, n Number, e Error, s String, d Date, z Empty
|
621 | */
|
622 | t: ExcelDataType;
|
623 |
|
624 | /** Cell formula (if applicable) */
|
625 | f?: string;
|
626 |
|
627 | /** Range of enclosing array if formula is array formula (if applicable) */
|
628 | F?: string;
|
629 |
|
630 | /** Rich text encoding (if applicable) */
|
631 | r?: any;
|
632 |
|
633 | /** HTML rendering of the rich text (if applicable) */
|
634 | h?: string;
|
635 |
|
636 | /** Comments associated with the cell */
|
637 | c?: Comments;
|
638 |
|
639 | /** Number format string associated with the cell (if requested) */
|
640 | z?: NumberFormat;
|
641 |
|
642 | /** Cell hyperlink object (.Target holds link, .tooltip is tooltip) */
|
643 | l?: Hyperlink;
|
644 |
|
645 | /** The style/theme of the cell (if applicable) */
|
646 | s?: any;
|
647 | }
|
648 |
|
649 | /** Simple Cell Address */
|
650 | export interface CellAddress {
|
651 | /** Column number */
|
652 | c: number;
|
653 | /** Row number */
|
654 | r: number;
|
655 | }
|
656 |
|
657 | /** Range object (representing ranges like "A1:B2") */
|
658 | export interface Range {
|
659 | /** Starting cell */
|
660 | s: CellAddress;
|
661 | /** Ending cell */
|
662 | e: CellAddress;
|
663 | }
|
664 |
|
665 | export interface Sheet2CSVOpts extends DateNFOption {
|
666 | /** Field Separator ("delimiter") */
|
667 | FS?: string;
|
668 |
|
669 | /** Record Separator ("row separator") */
|
670 | RS?: string;
|
671 |
|
672 | /** Remove trailing field separators in each record */
|
673 | strip?: boolean;
|
674 |
|
675 | /** Include blank lines in the CSV output */
|
676 | blankrows?: boolean;
|
677 |
|
678 | /** Skip hidden rows and columns in the CSV output */
|
679 | skipHidden?: boolean;
|
680 |
|
681 | /** Force quotes around fields */
|
682 | forceQuotes?: boolean;
|
683 |
|
684 | /** if true, return raw numbers; if false, return formatted numbers */
|
685 | rawNumbers?: boolean;
|
686 | }
|
687 |
|
688 | export interface OriginOption {
|
689 | /** Top-Left cell for operation (CellAddress or A1 string or row) */
|
690 | origin?: number | string | CellAddress;
|
691 | }
|
692 |
|
693 | export interface Sheet2HTMLOpts {
|
694 | /** TABLE element id attribute */
|
695 | id?: string;
|
696 |
|
697 | /** Add contenteditable to every cell */
|
698 | editable?: boolean;
|
699 |
|
700 | /** Header HTML */
|
701 | header?: string;
|
702 |
|
703 | /** Footer HTML */
|
704 | footer?: string;
|
705 | }
|
706 |
|
707 | export interface Sheet2JSONOpts extends DateNFOption {
|
708 | /** Output format */
|
709 | header?: "A"|number|string[];
|
710 |
|
711 | /** Override worksheet range */
|
712 | range?: any;
|
713 |
|
714 | /** Include or omit blank lines in the output */
|
715 | blankrows?: boolean;
|
716 |
|
717 | /** Default value for null/undefined values */
|
718 | defval?: any;
|
719 |
|
720 | /** if true, return raw data; if false, return formatted text */
|
721 | raw?: boolean;
|
722 |
|
723 | /** if true, skip hidden rows and columns */
|
724 | skipHidden?: boolean;
|
725 |
|
726 | /** if true, return raw numbers; if false, return formatted numbers */
|
727 | rawNumbers?: boolean;
|
728 | }
|
729 |
|
730 | export interface AOA2SheetOpts extends CommonOptions, DateNFOption {
|
731 | /**
|
732 | * Create cell objects for stub cells
|
733 | * @default false
|
734 | */
|
735 | sheetStubs?: boolean;
|
736 | }
|
737 |
|
738 | export interface SheetAOAOpts extends AOA2SheetOpts, OriginOption {}
|
739 |
|
740 | export interface JSON2SheetOpts extends CommonOptions, DateNFOption {
|
741 | /** Use specified column order */
|
742 | header?: string[];
|
743 |
|
744 | /** Skip header row in generated sheet */
|
745 | skipHeader?: boolean;
|
746 | }
|
747 |
|
748 | export interface SheetJSONOpts extends JSON2SheetOpts, OriginOption {}
|
749 |
|
750 | export interface Table2SheetOpts extends CommonOptions, DateNFOption, OriginOption, SheetOption {
|
751 | /** If true, plaintext parsing will not parse values */
|
752 | raw?: boolean;
|
753 |
|
754 | /**
|
755 | * If >0, read the first sheetRows rows
|
756 | * @default 0
|
757 | */
|
758 | sheetRows?: number;
|
759 |
|
760 | /** If true, hidden rows and cells will not be parsed */
|
761 | display?: boolean;
|
762 | }
|
763 |
|
764 | /** General utilities */
|
765 | export interface XLSX$Utils {
|
766 | /* --- Import Functions --- */
|
767 |
|
768 | /** Converts an array of arrays of JS data to a worksheet. */
|
769 | aoa_to_sheet<T>(data: T[][], opts?: AOA2SheetOpts): WorkSheet;
|
770 | aoa_to_sheet(data: any[][], opts?: AOA2SheetOpts): WorkSheet;
|
771 |
|
772 | /** Converts an array of JS objects to a worksheet. */
|
773 | json_to_sheet<T>(data: T[], opts?: JSON2SheetOpts): WorkSheet;
|
774 | json_to_sheet(data: any[], opts?: JSON2SheetOpts): WorkSheet;
|
775 |
|
776 | /** BROWSER ONLY! Converts a TABLE DOM element to a worksheet. */
|
777 | table_to_sheet(data: any, opts?: Table2SheetOpts): WorkSheet;
|
778 | table_to_book(data: any, opts?: Table2SheetOpts): WorkBook;
|
779 | sheet_add_dom(ws: WorkSheet, data: any, opts?: Table2SheetOpts): WorkSheet;
|
780 |
|
781 | /* --- Export Functions --- */
|
782 |
|
783 | /** Converts a worksheet object to an array of JSON objects */
|
784 | sheet_to_json<T>(worksheet: WorkSheet, opts?: Sheet2JSONOpts): T[];
|
785 | sheet_to_json(worksheet: WorkSheet, opts?: Sheet2JSONOpts): any[][];
|
786 | sheet_to_json(worksheet: WorkSheet, opts?: Sheet2JSONOpts): any[];
|
787 |
|
788 | /** Generates delimiter-separated-values output */
|
789 | sheet_to_csv(worksheet: WorkSheet, options?: Sheet2CSVOpts): string;
|
790 |
|
791 | /** Generates UTF16 Formatted Text */
|
792 | sheet_to_txt(worksheet: WorkSheet, options?: Sheet2CSVOpts): string;
|
793 |
|
794 | /** Generates HTML */
|
795 | sheet_to_html(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
|
796 |
|
797 | /** Generates a list of the formulae (with value fallbacks) */
|
798 | sheet_to_formulae(worksheet: WorkSheet): string[];
|
799 |
|
800 | /** Generates DIF */
|
801 | sheet_to_dif(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
|
802 |
|
803 | /** Generates SYLK (Symbolic Link) */
|
804 | sheet_to_slk(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
|
805 |
|
806 | /** Generates ETH */
|
807 | sheet_to_eth(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
|
808 |
|
809 | /* --- Cell Address Utilities --- */
|
810 |
|
811 | /** Converts 0-indexed cell address to A1 form */
|
812 | encode_cell(cell: CellAddress): string;
|
813 |
|
814 | /** Converts 0-indexed row to A1 form */
|
815 | encode_row(row: number): string;
|
816 |
|
817 | /** Converts 0-indexed column to A1 form */
|
818 | encode_col(col: number): string;
|
819 |
|
820 | /** Converts 0-indexed range to A1 form */
|
821 | encode_range(s: CellAddress, e: CellAddress): string;
|
822 | encode_range(r: Range): string;
|
823 |
|
824 | /** Converts A1 cell address to 0-indexed form */
|
825 | decode_cell(address: string): CellAddress;
|
826 |
|
827 | /** Converts A1 row to 0-indexed form */
|
828 | decode_row(row: string): number;
|
829 |
|
830 | /** Converts A1 column to 0-indexed form */
|
831 | decode_col(col: string): number;
|
832 |
|
833 | /** Converts A1 range to 0-indexed form */
|
834 | decode_range(range: string): Range;
|
835 |
|
836 | /** Format cell */
|
837 | format_cell(cell: CellObject, v?: any, opts?: any): string;
|
838 |
|
839 | /* --- General Utilities --- */
|
840 |
|
841 | /** Creates a new workbook */
|
842 | book_new(): WorkBook;
|
843 |
|
844 | /** Append a worksheet to a workbook */
|
845 | book_append_sheet(workbook: WorkBook, worksheet: WorkSheet, name?: string, roll?: boolean): void;
|
846 |
|
847 | /** Set sheet visibility (visible/hidden/very hidden) */
|
848 | book_set_sheet_visibility(workbook: WorkBook, sheet: number|string, visibility: number): void;
|
849 |
|
850 | /** Set number format for a cell */
|
851 | cell_set_number_format(cell: CellObject, fmt: string|number): CellObject;
|
852 |
|
853 | /** Set hyperlink for a cell */
|
854 | cell_set_hyperlink(cell: CellObject, target: string, tooltip?: string): CellObject;
|
855 |
|
856 | /** Set internal link for a cell */
|
857 | cell_set_internal_link(cell: CellObject, target: string, tooltip?: string): CellObject;
|
858 |
|
859 | /** Add comment to a cell */
|
860 | cell_add_comment(cell: CellObject, text: string, author?: string): void;
|
861 |
|
862 | /** Assign an Array Formula to a range */
|
863 | sheet_set_array_formula(ws: WorkSheet, range: Range|string, formula: string, dynamic?: boolean): WorkSheet;
|
864 |
|
865 | /** Add an array of arrays of JS data to a worksheet */
|
866 | sheet_add_aoa<T>(ws: WorkSheet, data: T[][], opts?: SheetAOAOpts): WorkSheet;
|
867 | sheet_add_aoa(ws: WorkSheet, data: any[][], opts?: SheetAOAOpts): WorkSheet;
|
868 |
|
869 | /** Add an array of JS objects to a worksheet */
|
870 | sheet_add_json(ws: WorkSheet, data: any[], opts?: SheetJSONOpts): WorkSheet;
|
871 | sheet_add_json<T>(ws: WorkSheet, data: T[], opts?: SheetJSONOpts): WorkSheet;
|
872 |
|
873 |
|
874 | consts: XLSX$Consts;
|
875 | }
|
876 |
|
877 | export interface XLSX$Consts {
|
878 | /* --- Sheet Visibility --- */
|
879 |
|
880 | /** Visibility: Visible */
|
881 | SHEET_VISIBLE: 0;
|
882 |
|
883 | /** Visibility: Hidden */
|
884 | SHEET_HIDDEN: 1;
|
885 |
|
886 | /** Visibility: Very Hidden */
|
887 | SHEET_VERYHIDDEN: 2;
|
888 | }
|
889 |
|
890 | /** NODE ONLY! these return Readable Streams */
|
891 | export interface StreamUtils {
|
892 | /** CSV output stream, generate one line at a time */
|
893 | to_csv(sheet: WorkSheet, opts?: Sheet2CSVOpts): any;
|
894 | /** HTML output stream, generate one line at a time */
|
895 | to_html(sheet: WorkSheet, opts?: Sheet2HTMLOpts): any;
|
896 | /** JSON object stream, generate one row at a time */
|
897 | to_json(sheet: WorkSheet, opts?: Sheet2JSONOpts): any;
|
898 | /** Set `Readable` (internal) */
|
899 | set_readable(Readable: any): void;
|
900 | }
|