2017-05-15 15:48:44 +00:00
|
|
|
/* index.d.ts (C) 2015-present SheetJS and contributors */
|
2017-05-13 23:31:56 +00:00
|
|
|
// TypeScript Version: 2.2
|
2018-02-14 20:06:35 +00:00
|
|
|
import * as CFB from "cfb";
|
2018-02-21 07:01:34 +00:00
|
|
|
import * as SSF from "ssf";
|
2015-06-03 13:34:42 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Version string */
|
|
|
|
export const version: string;
|
|
|
|
|
2017-07-05 22:27:54 +00:00
|
|
|
/** SSF Formatter Library */
|
2018-02-21 07:01:34 +00:00
|
|
|
export { SSF };
|
2017-07-05 10:24:46 +00:00
|
|
|
|
2017-12-04 04:41:41 +00:00
|
|
|
/** CFB Library */
|
2018-02-14 20:06:35 +00:00
|
|
|
export { CFB };
|
2017-12-04 04:41:41 +00:00
|
|
|
|
2018-02-03 20:46:32 +00:00
|
|
|
/** NODE ONLY! Attempts to read filename and parse */
|
2017-05-13 23:37:23 +00:00
|
|
|
export function readFile(filename: string, opts?: ParsingOptions): WorkBook;
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Attempts to parse data */
|
2017-05-13 23:37:23 +00:00
|
|
|
export function read(data: any, opts?: ParsingOptions): WorkBook;
|
2018-02-03 20:46:32 +00:00
|
|
|
/** Attempts to write or download workbook data to file */
|
2017-05-13 23:37:23 +00:00
|
|
|
export function writeFile(data: WorkBook, filename: string, opts?: WritingOptions): any;
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Attempts to write the workbook data */
|
2017-05-13 23:37:23 +00:00
|
|
|
export function write(data: WorkBook, opts?: WritingOptions): any;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Utility Functions */
|
2017-06-10 01:47:42 +00:00
|
|
|
export const utils: XLSX$Utils;
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Stream Utility Functions */
|
2017-05-16 17:45:35 +00:00
|
|
|
export const stream: StreamUtils;
|
|
|
|
|
|
|
|
/** Number Format (either a string or an index to the format table) */
|
|
|
|
export type NumberFormat = string | number;
|
2016-04-22 21:12:45 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Basic File Properties */
|
2017-05-13 23:37:23 +00:00
|
|
|
export interface Properties {
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Summary tab "Title" */
|
2017-05-15 15:48:44 +00:00
|
|
|
Title?: string;
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Summary tab "Subject" */
|
2017-05-15 15:48:44 +00:00
|
|
|
Subject?: string;
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Summary tab "Author" */
|
2016-04-22 21:12:45 +00:00
|
|
|
Author?: string;
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Summary tab "Manager" */
|
2017-05-15 15:48:44 +00:00
|
|
|
Manager?: string;
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Summary tab "Company" */
|
2017-05-15 15:48:44 +00:00
|
|
|
Company?: string;
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Summary tab "Category" */
|
2017-05-15 15:48:44 +00:00
|
|
|
Category?: string;
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Summary tab "Keywords" */
|
2017-05-15 15:48:44 +00:00
|
|
|
Keywords?: string;
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Summary tab "Comments" */
|
2017-05-15 15:48:44 +00:00
|
|
|
Comments?: string;
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Statistics tab "Last saved by" */
|
2017-05-15 15:48:44 +00:00
|
|
|
LastAuthor?: string;
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Statistics tab "Created" */
|
2016-04-22 21:12:45 +00:00
|
|
|
CreatedDate?: Date;
|
2017-05-16 17:45:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Other supported properties */
|
|
|
|
export interface FullProperties extends Properties {
|
2017-05-12 21:46:46 +00:00
|
|
|
ModifiedDate?: Date;
|
2016-04-22 21:12:45 +00:00
|
|
|
Application?: string;
|
|
|
|
AppVersion?: string;
|
|
|
|
DocSecurity?: string;
|
|
|
|
HyperlinksChanged?: boolean;
|
|
|
|
SharedDoc?: boolean;
|
|
|
|
LinksUpToDate?: boolean;
|
|
|
|
ScaleCrop?: boolean;
|
|
|
|
Worksheets?: number;
|
|
|
|
SheetNames?: string[];
|
2017-05-16 17:45:35 +00:00
|
|
|
ContentStatus?: string;
|
|
|
|
LastPrinted?: string;
|
|
|
|
Revision?: string | number;
|
|
|
|
Version?: string;
|
|
|
|
Identifier?: string;
|
|
|
|
Language?: string;
|
2016-04-22 21:12:45 +00:00
|
|
|
}
|
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
export interface CommonOptions {
|
2017-03-12 07:21:11 +00:00
|
|
|
/**
|
2017-05-16 17:45:35 +00:00
|
|
|
* If true, throw errors when features are not understood
|
|
|
|
* @default false
|
2017-03-12 07:21:11 +00:00
|
|
|
*/
|
2017-05-16 17:45:35 +00:00
|
|
|
WTF?: boolean;
|
|
|
|
|
2017-12-04 04:41:41 +00:00
|
|
|
/**
|
|
|
|
* When reading a file with VBA macros, expose CFB blob to `vbaraw` field
|
|
|
|
* When writing BIFF8/XLSB/XLSM, reseat `vbaraw` and export to file
|
|
|
|
* @default false
|
|
|
|
*/
|
|
|
|
bookVBA?: boolean;
|
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/**
|
|
|
|
* When reading a file, store dates as type d (default is n)
|
|
|
|
* When writing XLSX/XLSM file, use native date (default uses date codes)
|
|
|
|
* @default false
|
|
|
|
*/
|
|
|
|
cellDates?: boolean;
|
2017-12-04 04:41:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* When reading a file, save style/theme info to the .s field
|
|
|
|
* When writing a file, export style/theme info
|
|
|
|
* @default false
|
|
|
|
*/
|
|
|
|
cellStyles?: boolean;
|
2017-05-16 17:45:35 +00:00
|
|
|
}
|
|
|
|
|
2017-08-09 22:38:23 +00:00
|
|
|
export interface DateNFOption {
|
|
|
|
/** Use specified date format */
|
|
|
|
dateNF?: NumberFormat;
|
|
|
|
}
|
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Options for read and readFile */
|
|
|
|
export interface ParsingOptions extends CommonOptions {
|
|
|
|
/** Input data encoding */
|
2018-03-07 13:49:25 +00:00
|
|
|
type?: 'base64' | 'binary' | 'buffer' | 'file' | 'array' | 'string';
|
2017-03-12 07:21:11 +00:00
|
|
|
|
2017-12-30 05:40:35 +00:00
|
|
|
/** Default codepage */
|
|
|
|
codepage?: number;
|
|
|
|
|
2017-03-12 07:21:11 +00:00
|
|
|
/**
|
|
|
|
* Save formulae to the .f field
|
|
|
|
* @default true
|
|
|
|
*/
|
2016-04-22 21:12:45 +00:00
|
|
|
cellFormula?: boolean;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse rich text and save HTML to the .h field
|
|
|
|
* @default true
|
|
|
|
*/
|
2016-04-22 21:12:45 +00:00
|
|
|
cellHTML?: boolean;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Save number format string to the .z field
|
|
|
|
* @default false
|
|
|
|
*/
|
2016-04-22 21:12:45 +00:00
|
|
|
cellNF?: boolean;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
2017-05-16 17:45:35 +00:00
|
|
|
* Generate formatted text to the .w field
|
|
|
|
* @default true
|
2017-03-12 07:21:11 +00:00
|
|
|
*/
|
2017-05-16 17:45:35 +00:00
|
|
|
cellText?: boolean;
|
|
|
|
|
|
|
|
/** Override default date format (code 14) */
|
|
|
|
dateNF?: string;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create cell objects for stub cells
|
|
|
|
* @default false
|
|
|
|
*/
|
2016-04-22 21:12:45 +00:00
|
|
|
sheetStubs?: boolean;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If >0, read the first sheetRows rows
|
|
|
|
* @default 0
|
|
|
|
*/
|
2016-04-22 21:12:45 +00:00
|
|
|
sheetRows?: number;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If true, parse calculation chains
|
|
|
|
* @default false
|
|
|
|
*/
|
2016-04-22 21:12:45 +00:00
|
|
|
bookDeps?: boolean;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If true, add raw files to book object
|
|
|
|
* @default false
|
|
|
|
*/
|
2016-04-22 21:12:45 +00:00
|
|
|
bookFiles?: boolean;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If true, only parse enough to get book metadata
|
|
|
|
* @default false
|
|
|
|
*/
|
2016-04-22 21:12:45 +00:00
|
|
|
bookProps?: boolean;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If true, only parse enough to get the sheet names
|
|
|
|
* @default false
|
|
|
|
*/
|
2016-04-22 21:12:45 +00:00
|
|
|
bookSheets?: boolean;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If defined and file is encrypted, use password
|
|
|
|
* @default ''
|
|
|
|
*/
|
2016-04-22 21:12:45 +00:00
|
|
|
password?: string;
|
2017-08-09 22:38:23 +00:00
|
|
|
|
|
|
|
/* If true, plaintext parsing will not parse values */
|
|
|
|
raw?: boolean;
|
2017-09-22 22:18:51 +00:00
|
|
|
|
|
|
|
dense?: boolean;
|
2017-03-12 07:21:11 +00:00
|
|
|
}
|
2016-04-22 21:12:45 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Options for write and writeFile */
|
|
|
|
export interface WritingOptions extends CommonOptions {
|
|
|
|
/** Output data encoding */
|
2018-03-07 13:49:25 +00:00
|
|
|
type?: 'base64' | 'binary' | 'buffer' | 'file' | 'array' | 'string';
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate Shared String Table
|
|
|
|
* @default false
|
|
|
|
*/
|
|
|
|
bookSST?: boolean;
|
|
|
|
|
|
|
|
/**
|
2017-05-16 17:45:35 +00:00
|
|
|
* File format of generated workbook
|
2017-03-12 07:21:11 +00:00
|
|
|
* @default 'xlsx'
|
|
|
|
*/
|
2017-05-16 17:45:35 +00:00
|
|
|
bookType?: BookType;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/**
|
2017-05-16 17:45:35 +00:00
|
|
|
* Name of Worksheet (for single-sheet formats)
|
2017-03-12 07:21:11 +00:00
|
|
|
* @default ''
|
|
|
|
*/
|
|
|
|
sheet?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use ZIP compression for ZIP-based formats
|
|
|
|
* @default false
|
|
|
|
*/
|
|
|
|
compression?: boolean;
|
2017-05-16 17:45:35 +00:00
|
|
|
|
2018-08-15 19:22:47 +00:00
|
|
|
/**
|
|
|
|
* Suppress "number stored as text" errors in generated files
|
|
|
|
* @default true
|
|
|
|
*/
|
|
|
|
ignoreEC?: boolean;
|
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Override workbook properties on save */
|
|
|
|
Props?: Properties;
|
2016-04-22 21:12:45 +00:00
|
|
|
}
|
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Workbook Object */
|
2017-05-13 23:37:23 +00:00
|
|
|
export interface WorkBook {
|
2016-04-22 21:12:45 +00:00
|
|
|
/**
|
|
|
|
* A dictionary of the worksheets in the workbook.
|
|
|
|
* Use SheetNames to reference these.
|
|
|
|
*/
|
2017-05-13 23:37:23 +00:00
|
|
|
Sheets: { [sheet: string]: WorkSheet };
|
2016-04-22 21:12:45 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Ordered list of the sheet names in the workbook */
|
2016-04-22 21:12:45 +00:00
|
|
|
SheetNames: string[];
|
|
|
|
|
2018-05-05 06:34:37 +00:00
|
|
|
/** Standard workbook Properties */
|
2017-05-16 17:45:35 +00:00
|
|
|
Props?: FullProperties;
|
2017-05-15 15:48:44 +00:00
|
|
|
|
2018-05-05 06:34:37 +00:00
|
|
|
/** Custom workbook Properties */
|
|
|
|
Custprops?: object;
|
|
|
|
|
2017-05-15 15:48:44 +00:00
|
|
|
Workbook?: WBProps;
|
2017-12-04 04:41:41 +00:00
|
|
|
|
|
|
|
vbaraw?: any;
|
2017-05-15 15:48:44 +00:00
|
|
|
}
|
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
export interface SheetProps {
|
|
|
|
/** Sheet Visibility (0=Visible 1=Hidden 2=VeryHidden) */
|
|
|
|
Hidden?: 0 | 1 | 2;
|
2017-11-20 01:51:14 +00:00
|
|
|
|
|
|
|
/** Name of Document Module in associated VBA Project */
|
|
|
|
CodeName?: string;
|
2017-05-16 17:45:35 +00:00
|
|
|
}
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Defined Name Object */
|
2017-05-16 17:45:35 +00:00
|
|
|
export interface DefinedName {
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Name */
|
2017-05-16 17:45:35 +00:00
|
|
|
Name: string;
|
2017-06-19 07:14:14 +00:00
|
|
|
|
|
|
|
/** Reference */
|
2017-05-16 17:45:35 +00:00
|
|
|
Ref: string;
|
2017-06-19 07:14:14 +00:00
|
|
|
|
|
|
|
/** Scope (undefined for workbook scope) */
|
2017-05-16 17:45:35 +00:00
|
|
|
Sheet?: number;
|
2017-06-19 07:14:14 +00:00
|
|
|
|
|
|
|
/** Name comment */
|
2017-05-16 17:45:35 +00:00
|
|
|
Comment?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Workbook-Level Attributes */
|
2017-05-15 15:48:44 +00:00
|
|
|
export interface WBProps {
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Sheet Properties */
|
|
|
|
Sheets?: SheetProps[];
|
|
|
|
|
|
|
|
/** Defined Names */
|
|
|
|
Names?: DefinedName[];
|
2017-06-01 21:22:11 +00:00
|
|
|
|
2017-12-25 02:25:03 +00:00
|
|
|
/** Workbook Views */
|
2017-12-30 05:40:35 +00:00
|
|
|
Views?: WBView[];
|
2017-12-25 02:25:03 +00:00
|
|
|
|
2017-06-01 21:22:11 +00:00
|
|
|
/** Other Workbook Properties */
|
|
|
|
WBProps?: WorkbookProperties;
|
|
|
|
}
|
|
|
|
|
2017-12-30 05:40:35 +00:00
|
|
|
/** Workbook View */
|
|
|
|
export interface WBView {
|
|
|
|
/** Right-to-left mode */
|
|
|
|
RTL?: boolean;
|
|
|
|
}
|
|
|
|
|
2017-06-01 21:22:11 +00:00
|
|
|
/** Other Workbook Properties */
|
|
|
|
export interface WorkbookProperties {
|
|
|
|
/** Worksheet Epoch (1904 if true, 1900 if false) */
|
|
|
|
date1904?: boolean;
|
2017-06-03 07:19:09 +00:00
|
|
|
|
|
|
|
/** Warn or strip personally identifying info on save */
|
|
|
|
filterPrivacy?: boolean;
|
2017-11-20 01:51:14 +00:00
|
|
|
|
|
|
|
/** Name of Document Module in associated VBA Project */
|
|
|
|
CodeName?: string;
|
2016-04-22 21:12:45 +00:00
|
|
|
}
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Column Properties Object */
|
2017-05-13 23:37:23 +00:00
|
|
|
export interface ColInfo {
|
2017-05-16 17:45:35 +00:00
|
|
|
/* --- visibility --- */
|
|
|
|
|
|
|
|
/** if true, the column is hidden */
|
|
|
|
hidden?: boolean;
|
|
|
|
|
|
|
|
/* --- column width --- */
|
|
|
|
|
|
|
|
/** width in Excel's "Max Digit Width", width*256 is integral */
|
2017-05-15 15:48:44 +00:00
|
|
|
width?: number;
|
2017-05-16 17:45:35 +00:00
|
|
|
|
|
|
|
/** width in screen pixels */
|
2017-05-12 21:46:24 +00:00
|
|
|
wpx?: number;
|
2017-05-16 17:45:35 +00:00
|
|
|
|
|
|
|
/** width in "characters" */
|
2017-05-12 21:46:24 +00:00
|
|
|
wch?: number;
|
2017-05-16 17:45:35 +00:00
|
|
|
|
|
|
|
/** Excel's "Max Digit Width" unit, always integral */
|
|
|
|
MDW?: number;
|
2017-05-12 21:46:24 +00:00
|
|
|
}
|
2017-06-19 07:14:14 +00:00
|
|
|
|
|
|
|
/** Row Properties Object */
|
2017-05-13 23:37:23 +00:00
|
|
|
export interface RowInfo {
|
2017-05-16 17:45:35 +00:00
|
|
|
/* --- visibility --- */
|
|
|
|
|
|
|
|
/** if true, the column is hidden */
|
|
|
|
hidden?: boolean;
|
|
|
|
|
|
|
|
/* --- row height --- */
|
|
|
|
|
|
|
|
/** height in screen pixels */
|
2017-05-12 21:46:24 +00:00
|
|
|
hpx?: number;
|
2017-05-16 17:45:35 +00:00
|
|
|
|
|
|
|
/** height in points */
|
2017-05-12 21:46:24 +00:00
|
|
|
hpt?: number;
|
2017-09-22 22:18:51 +00:00
|
|
|
|
|
|
|
/** outline / group level */
|
|
|
|
level?: number;
|
2017-05-12 21:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write sheet protection properties.
|
|
|
|
*/
|
2017-05-13 23:37:23 +00:00
|
|
|
export interface ProtectInfo {
|
2017-05-12 21:46:24 +00:00
|
|
|
/**
|
|
|
|
* The password for formats that support password-protected sheets
|
|
|
|
* (XLSX/XLSB/XLS). The writer uses the XOR obfuscation method.
|
|
|
|
*/
|
|
|
|
password?: string;
|
|
|
|
/**
|
|
|
|
* Select locked cells
|
|
|
|
* @default: true
|
|
|
|
*/
|
|
|
|
selectLockedCells?: boolean;
|
|
|
|
/**
|
|
|
|
* Select unlocked cells
|
|
|
|
* @default: true
|
|
|
|
*/
|
|
|
|
selectUnlockedCells?: boolean;
|
|
|
|
/**
|
|
|
|
* Format cells
|
|
|
|
* @default: false
|
|
|
|
*/
|
|
|
|
formatCells?: boolean;
|
|
|
|
/**
|
|
|
|
* Format columns
|
|
|
|
* @default: false
|
|
|
|
*/
|
|
|
|
formatColumns?: boolean;
|
|
|
|
/**
|
|
|
|
* Format rows
|
|
|
|
* @default: false
|
|
|
|
*/
|
|
|
|
formatRows?: boolean;
|
|
|
|
/**
|
|
|
|
* Insert columns
|
|
|
|
* @default: false
|
|
|
|
*/
|
|
|
|
insertColumns?: boolean;
|
|
|
|
/**
|
|
|
|
* Insert rows
|
|
|
|
* @default: false
|
|
|
|
*/
|
|
|
|
insertRows?: boolean;
|
|
|
|
/**
|
|
|
|
* Insert hyperlinks
|
|
|
|
* @default: false
|
|
|
|
*/
|
|
|
|
insertHyperlinks?: boolean;
|
|
|
|
/**
|
|
|
|
* Delete columns
|
|
|
|
* @default: false
|
|
|
|
*/
|
|
|
|
deleteColumns?: boolean;
|
|
|
|
/**
|
|
|
|
* Delete rows
|
|
|
|
* @default: false
|
|
|
|
*/
|
|
|
|
deleteRows?: boolean;
|
|
|
|
/**
|
|
|
|
* Sort
|
|
|
|
* @default: false
|
|
|
|
*/
|
|
|
|
sort?: boolean;
|
|
|
|
/**
|
|
|
|
* Filter
|
|
|
|
* @default: false
|
|
|
|
*/
|
|
|
|
autoFilter?: boolean;
|
|
|
|
/**
|
|
|
|
* Use PivotTable reports
|
|
|
|
* @default: false
|
|
|
|
*/
|
|
|
|
pivotTables?: boolean;
|
|
|
|
/**
|
|
|
|
* Edit objects
|
|
|
|
* @default: true
|
|
|
|
*/
|
|
|
|
objects?: boolean;
|
|
|
|
/**
|
|
|
|
* Edit scenarios
|
|
|
|
* @default: true
|
|
|
|
*/
|
|
|
|
scenarios?: boolean;
|
|
|
|
}
|
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Page Margins -- see Excel Page Setup .. Margins diagram for explanation */
|
|
|
|
export interface MarginInfo {
|
|
|
|
/** Left side margin (inches) */
|
|
|
|
left?: number;
|
|
|
|
/** Right side margin (inches) */
|
|
|
|
right?: number;
|
|
|
|
/** Top side margin (inches) */
|
|
|
|
top?: number;
|
|
|
|
/** Bottom side margin (inches) */
|
|
|
|
bottom?: number;
|
|
|
|
/** Header top margin (inches) */
|
|
|
|
header?: number;
|
|
|
|
/** Footer bottom height (inches) */
|
|
|
|
footer?: number;
|
|
|
|
}
|
|
|
|
export type SheetType = 'sheet' | 'chart';
|
|
|
|
export type SheetKeys = string | MarginInfo | SheetType;
|
|
|
|
/** General object representing a Sheet (worksheet or chartsheet) */
|
2017-05-13 23:37:23 +00:00
|
|
|
export interface Sheet {
|
2017-05-16 17:45:35 +00:00
|
|
|
/**
|
|
|
|
* Indexing with a cell address string maps to a cell object
|
|
|
|
* Special keys start with '!'
|
|
|
|
*/
|
|
|
|
[cell: string]: CellObject | SheetKeys | any;
|
|
|
|
|
|
|
|
/** Sheet type */
|
|
|
|
'!type'?: SheetType;
|
|
|
|
|
|
|
|
/** Sheet Range */
|
2017-05-12 21:46:24 +00:00
|
|
|
'!ref'?: string;
|
2017-05-16 17:45:35 +00:00
|
|
|
|
|
|
|
/** Page Margins */
|
|
|
|
'!margins'?: MarginInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** AutoFilter properties */
|
|
|
|
export interface AutoFilterInfo {
|
|
|
|
/** Range of the AutoFilter table */
|
|
|
|
ref: string;
|
2017-05-12 21:46:24 +00:00
|
|
|
}
|
2017-05-16 17:45:35 +00:00
|
|
|
export type WSKeys = SheetKeys | ColInfo[] | RowInfo[] | Range[] | ProtectInfo | AutoFilterInfo;
|
2017-05-12 21:46:24 +00:00
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Worksheet Object */
|
2017-05-13 23:37:23 +00:00
|
|
|
export interface WorkSheet extends Sheet {
|
2017-05-16 17:45:35 +00:00
|
|
|
/**
|
|
|
|
* Indexing with a cell address string maps to a cell object
|
|
|
|
* Special keys start with '!'
|
|
|
|
*/
|
|
|
|
[cell: string]: CellObject | WSKeys | any;
|
2017-06-19 07:14:14 +00:00
|
|
|
|
|
|
|
/** Column Info */
|
2017-05-13 23:37:23 +00:00
|
|
|
'!cols'?: ColInfo[];
|
2017-06-19 07:14:14 +00:00
|
|
|
|
|
|
|
/** Row Info */
|
2017-05-13 23:37:23 +00:00
|
|
|
'!rows'?: RowInfo[];
|
2017-06-19 07:14:14 +00:00
|
|
|
|
|
|
|
/** Merge Ranges */
|
2017-05-13 23:37:23 +00:00
|
|
|
'!merges'?: Range[];
|
2017-06-19 07:14:14 +00:00
|
|
|
|
|
|
|
/** Worksheet Protection info */
|
2017-05-13 23:37:23 +00:00
|
|
|
'!protect'?: ProtectInfo;
|
2017-06-19 07:14:14 +00:00
|
|
|
|
|
|
|
/** AutoFilter info */
|
2017-05-16 17:45:35 +00:00
|
|
|
'!autofilter'?: AutoFilterInfo;
|
2016-04-22 21:12:45 +00:00
|
|
|
}
|
|
|
|
|
2017-05-12 21:46:31 +00:00
|
|
|
/**
|
2017-05-12 21:46:39 +00:00
|
|
|
* The Excel data type for a cell.
|
2017-06-19 07:14:14 +00:00
|
|
|
* b Boolean, n Number, e error, s String, d Date, z Stub
|
2017-05-12 21:46:39 +00:00
|
|
|
*/
|
2017-05-15 15:48:44 +00:00
|
|
|
export type ExcelDataType = 'b' | 'n' | 'e' | 's' | 'd' | 'z';
|
2017-05-12 21:46:31 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/**
|
|
|
|
* Type of generated workbook
|
|
|
|
* @default 'xlsx'
|
|
|
|
*/
|
2017-12-30 05:40:35 +00:00
|
|
|
export type BookType = 'xlsx' | 'xlsm' | 'xlsb' | 'xls' | 'xla' | 'biff8' | 'biff5' | 'biff2' | 'xlml' | 'ods' | 'fods' | 'csv' | 'txt' | 'sylk' | 'html' | 'dif' | 'rtf' | 'prn' | 'eth';
|
2017-05-16 17:45:35 +00:00
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Comment element */
|
2017-05-16 17:45:35 +00:00
|
|
|
export interface Comment {
|
|
|
|
/** Author of the comment block */
|
|
|
|
a?: string;
|
|
|
|
|
|
|
|
/** Plaintext of the comment */
|
|
|
|
t: string;
|
|
|
|
}
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Link object */
|
2017-05-16 17:45:35 +00:00
|
|
|
export interface Hyperlink {
|
|
|
|
/** Target of the link (HREF) */
|
|
|
|
Target: string;
|
|
|
|
|
|
|
|
/** Plaintext tooltip to display when mouse is over cell */
|
|
|
|
Tooltip?: string;
|
|
|
|
}
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Worksheet Cell Object */
|
2017-05-15 15:48:44 +00:00
|
|
|
export interface CellObject {
|
2017-05-16 17:45:35 +00:00
|
|
|
/** The raw value of the cell. Can be omitted if a formula is specified */
|
|
|
|
v?: string | number | boolean | Date;
|
2016-04-22 21:12:45 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Formatted text (if applicable) */
|
2017-03-12 07:21:11 +00:00
|
|
|
w?: string;
|
2016-04-22 21:12:45 +00:00
|
|
|
|
|
|
|
/**
|
2017-05-12 21:46:39 +00:00
|
|
|
* The Excel Data Type of the cell.
|
2017-05-16 17:45:35 +00:00
|
|
|
* b Boolean, n Number, e Error, s String, d Date, z Empty
|
2017-05-12 21:46:39 +00:00
|
|
|
*/
|
2017-05-12 21:46:31 +00:00
|
|
|
t: ExcelDataType;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Cell formula (if applicable) */
|
2017-03-12 07:21:11 +00:00
|
|
|
f?: string;
|
2016-04-22 21:12:45 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Range of enclosing array if formula is array formula (if applicable) */
|
2017-03-12 07:21:11 +00:00
|
|
|
F?: string;
|
2016-04-22 21:12:45 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Rich text encoding (if applicable) */
|
|
|
|
r?: any;
|
2016-04-22 21:12:45 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** HTML rendering of the rich text (if applicable) */
|
2017-03-12 07:21:11 +00:00
|
|
|
h?: string;
|
2016-04-22 21:12:45 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Comments associated with the cell */
|
|
|
|
c?: Comment[];
|
2016-04-22 21:12:45 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Number format string associated with the cell (if requested) */
|
|
|
|
z?: NumberFormat;
|
2016-04-22 21:12:45 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Cell hyperlink object (.Target holds link, .tooltip is tooltip) */
|
|
|
|
l?: Hyperlink;
|
2015-06-03 13:34:42 +00:00
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** The style/theme of the cell (if applicable) */
|
2017-07-27 16:06:55 +00:00
|
|
|
s?: any;
|
2016-04-22 21:12:45 +00:00
|
|
|
}
|
2015-06-03 13:34:42 +00:00
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Simple Cell Address */
|
2017-05-15 15:48:44 +00:00
|
|
|
export interface CellAddress {
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Column number */
|
2016-08-11 20:18:32 +00:00
|
|
|
c: number;
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Row number */
|
2016-08-11 20:18:32 +00:00
|
|
|
r: number;
|
|
|
|
}
|
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/**
|
|
|
|
* Range object (representing ranges like "A1:B2")
|
|
|
|
*/
|
2017-05-13 23:37:23 +00:00
|
|
|
export interface Range {
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Starting cell */
|
2017-05-15 15:48:44 +00:00
|
|
|
s: CellAddress;
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Ending cell */
|
2017-05-15 15:48:44 +00:00
|
|
|
e: CellAddress;
|
2016-11-22 23:08:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-09 22:38:23 +00:00
|
|
|
export interface Sheet2CSVOpts extends DateNFOption {
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Field Separator ("delimiter") */
|
|
|
|
FS?: string;
|
|
|
|
|
|
|
|
/** Record Separator ("row separator") */
|
|
|
|
RS?: string;
|
|
|
|
|
2017-08-05 06:32:57 +00:00
|
|
|
/** Remove trailing field separators in each record */
|
|
|
|
strip?: boolean;
|
|
|
|
|
|
|
|
/** Include blank lines in the CSV output */
|
|
|
|
blankrows?: boolean;
|
|
|
|
|
|
|
|
/** Skip hidden rows and columns in the CSV output */
|
|
|
|
skipHidden?: boolean;
|
2017-05-16 17:45:35 +00:00
|
|
|
}
|
|
|
|
|
2018-01-09 07:36:02 +00:00
|
|
|
export interface OriginOption {
|
|
|
|
/** Top-Left cell for operation (CellAddress or A1 string or row) */
|
|
|
|
origin?: number | string | CellAddress;
|
|
|
|
}
|
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
export interface Sheet2HTMLOpts {
|
2018-02-03 20:46:32 +00:00
|
|
|
/** TABLE element id attribute */
|
|
|
|
id?: string;
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Add contenteditable to every cell */
|
2017-05-16 17:45:35 +00:00
|
|
|
editable?: boolean;
|
2017-08-05 06:32:57 +00:00
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Header HTML */
|
2017-05-16 17:45:35 +00:00
|
|
|
header?: string;
|
2017-08-05 06:32:57 +00:00
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Footer HTML */
|
2017-05-16 17:45:35 +00:00
|
|
|
footer?: string;
|
|
|
|
}
|
|
|
|
|
2017-08-09 22:38:23 +00:00
|
|
|
export interface Sheet2JSONOpts extends DateNFOption {
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Output format */
|
2017-05-16 17:45:35 +00:00
|
|
|
header?: "A"|number|string[];
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Override worksheet range */
|
2017-05-16 17:45:35 +00:00
|
|
|
range?: any;
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Include or omit blank lines in the output */
|
|
|
|
blankrows?: boolean;
|
|
|
|
|
|
|
|
/** Default value for null/undefined values */
|
|
|
|
defval?: any;
|
|
|
|
|
|
|
|
/** if true, return raw data; if false, return formatted text */
|
2017-05-16 17:45:35 +00:00
|
|
|
raw?: boolean;
|
|
|
|
}
|
|
|
|
|
2017-08-09 22:38:23 +00:00
|
|
|
export interface AOA2SheetOpts extends CommonOptions, DateNFOption {
|
2017-05-16 17:45:35 +00:00
|
|
|
/**
|
|
|
|
* Create cell objects for stub cells
|
|
|
|
* @default false
|
|
|
|
*/
|
|
|
|
sheetStubs?: boolean;
|
|
|
|
}
|
|
|
|
|
2018-01-09 07:36:02 +00:00
|
|
|
export interface SheetAOAOpts extends AOA2SheetOpts, OriginOption {}
|
|
|
|
|
2017-08-09 22:38:23 +00:00
|
|
|
export interface JSON2SheetOpts extends CommonOptions, DateNFOption {
|
|
|
|
/** Use specified column order */
|
|
|
|
header?: string[];
|
2018-01-09 07:36:02 +00:00
|
|
|
|
|
|
|
/** Skip header row in generated sheet */
|
|
|
|
skipHeader?: boolean;
|
2017-05-16 17:45:35 +00:00
|
|
|
}
|
|
|
|
|
2018-01-09 07:36:02 +00:00
|
|
|
export interface SheetJSONOpts extends JSON2SheetOpts, OriginOption {}
|
|
|
|
|
2017-08-09 22:38:23 +00:00
|
|
|
export interface Table2SheetOpts extends CommonOptions, DateNFOption {
|
|
|
|
/* If true, plaintext parsing will not parse values */
|
|
|
|
raw?: boolean;
|
2018-04-06 06:39:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If >0, read the first sheetRows rows
|
|
|
|
* @default 0
|
|
|
|
*/
|
|
|
|
sheetRows?: number;
|
2018-05-27 07:27:47 +00:00
|
|
|
|
|
|
|
/** If true, hidden rows and cells will not be parsed */
|
|
|
|
display?: boolean;
|
2017-05-16 17:45:35 +00:00
|
|
|
}
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** General utilities */
|
2017-06-10 01:47:42 +00:00
|
|
|
export interface XLSX$Utils {
|
2017-05-16 17:45:35 +00:00
|
|
|
/* --- Import Functions --- */
|
|
|
|
|
|
|
|
/** Converts an array of arrays of JS data to a worksheet. */
|
|
|
|
aoa_to_sheet<T>(data: T[][], opts?: AOA2SheetOpts): WorkSheet;
|
|
|
|
aoa_to_sheet(data: any[][], opts?: AOA2SheetOpts): WorkSheet;
|
|
|
|
|
|
|
|
/** Converts an array of JS objects to a worksheet. */
|
|
|
|
json_to_sheet<T>(data: T[], opts?: JSON2SheetOpts): WorkSheet;
|
|
|
|
json_to_sheet(data: any[], opts?: JSON2SheetOpts): WorkSheet;
|
2017-05-15 15:48:44 +00:00
|
|
|
|
2017-07-10 22:18:18 +00:00
|
|
|
/** BROWSER ONLY! Converts a TABLE DOM element to a worksheet. */
|
|
|
|
table_to_sheet(data: any, opts?: Table2SheetOpts): WorkSheet;
|
|
|
|
table_to_book(data: any, opts?: Table2SheetOpts): WorkBook;
|
2017-05-16 17:45:35 +00:00
|
|
|
|
|
|
|
/* --- Export Functions --- */
|
2017-04-14 20:37:22 +00:00
|
|
|
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Converts a worksheet object to an array of JSON objects */
|
2017-05-16 17:45:35 +00:00
|
|
|
sheet_to_json<T>(worksheet: WorkSheet, opts?: Sheet2JSONOpts): T[];
|
|
|
|
sheet_to_json(worksheet: WorkSheet, opts?: Sheet2JSONOpts): any[][];
|
|
|
|
sheet_to_json(worksheet: WorkSheet, opts?: Sheet2JSONOpts): any[];
|
2017-05-15 15:48:44 +00:00
|
|
|
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Generates delimiter-separated-values output */
|
2017-05-16 17:45:35 +00:00
|
|
|
sheet_to_csv(worksheet: WorkSheet, options?: Sheet2CSVOpts): string;
|
|
|
|
|
2017-12-01 05:48:10 +00:00
|
|
|
/** Generates UTF16 Formatted Text */
|
|
|
|
sheet_to_txt(worksheet: WorkSheet, options?: Sheet2CSVOpts): string;
|
|
|
|
|
2017-05-16 17:45:35 +00:00
|
|
|
/** Generates HTML */
|
|
|
|
sheet_to_html(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
|
2017-05-15 15:48:44 +00:00
|
|
|
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Generates a list of the formulae (with value fallbacks) */
|
2017-05-16 17:45:35 +00:00
|
|
|
sheet_to_formulae(worksheet: WorkSheet): string[];
|
2017-03-12 07:21:11 +00:00
|
|
|
|
2017-12-04 04:41:41 +00:00
|
|
|
/** Generates DIF */
|
|
|
|
sheet_to_dif(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
|
|
|
|
|
|
|
|
/** Generates SYLK (Symbolic Link) */
|
|
|
|
sheet_to_slk(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
|
|
|
|
|
|
|
|
/** Generates ETH */
|
|
|
|
sheet_to_eth(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
|
|
|
|
|
2017-05-15 15:48:44 +00:00
|
|
|
/* --- Cell Address Utilities --- */
|
|
|
|
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Converts 0-indexed cell address to A1 form */
|
2017-05-15 15:48:44 +00:00
|
|
|
encode_cell(cell: CellAddress): string;
|
|
|
|
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Converts 0-indexed row to A1 form */
|
|
|
|
encode_row(row: number): string;
|
2017-05-15 15:48:44 +00:00
|
|
|
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Converts 0-indexed column to A1 form */
|
|
|
|
encode_col(col: number): string;
|
2017-05-15 15:48:44 +00:00
|
|
|
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Converts 0-indexed range to A1 form */
|
2017-05-15 15:48:44 +00:00
|
|
|
encode_range(s: CellAddress, e: CellAddress): string;
|
2017-05-16 17:45:35 +00:00
|
|
|
encode_range(r: Range): string;
|
2017-03-12 07:21:11 +00:00
|
|
|
|
|
|
|
/** Converts A1 cell address to 0-indexed form */
|
2017-05-15 15:48:44 +00:00
|
|
|
decode_cell(address: string): CellAddress;
|
|
|
|
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Converts A1 row to 0-indexed form */
|
|
|
|
decode_row(row: string): number;
|
2017-05-15 15:48:44 +00:00
|
|
|
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Converts A1 column to 0-indexed form */
|
|
|
|
decode_col(col: string): number;
|
2017-05-15 15:48:44 +00:00
|
|
|
|
2017-03-12 07:21:11 +00:00
|
|
|
/** Converts A1 range to 0-indexed form */
|
2017-05-13 23:37:23 +00:00
|
|
|
decode_range(range: string): Range;
|
2017-06-17 20:45:03 +00:00
|
|
|
|
2018-03-13 02:51:54 +00:00
|
|
|
/** Format cell */
|
|
|
|
format_cell(cell: CellObject, v?: any, opts?: any): string;
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/* --- General Utilities --- */
|
2017-06-17 20:45:03 +00:00
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Creates a new workbook */
|
2017-06-17 20:45:03 +00:00
|
|
|
book_new(): WorkBook;
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Append a worksheet to a workbook */
|
|
|
|
book_append_sheet(workbook: WorkBook, worksheet: WorkSheet, name?: string): void;
|
|
|
|
|
|
|
|
/** Set sheet visibility (visible/hidden/very hidden) */
|
|
|
|
book_set_sheet_visibility(workbook: WorkBook, sheet: number|string, visibility: number): void;
|
|
|
|
|
|
|
|
/** Set number format for a cell */
|
|
|
|
cell_set_number_format(cell: CellObject, fmt: string|number): CellObject;
|
|
|
|
|
|
|
|
/** Set hyperlink for a cell */
|
|
|
|
cell_set_hyperlink(cell: CellObject, target: string, tooltip?: string): CellObject;
|
|
|
|
|
2017-12-15 01:18:40 +00:00
|
|
|
/** Set internal link for a cell */
|
|
|
|
cell_set_internal_link(cell: CellObject, target: string, tooltip?: string): CellObject;
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
/** Add comment to a cell */
|
|
|
|
cell_add_comment(cell: CellObject, text: string, author?: string): void;
|
|
|
|
|
|
|
|
/** Assign an Array Formula to a range */
|
|
|
|
sheet_set_array_formula(ws: WorkSheet, range: Range|string, formula: string): WorkSheet;
|
|
|
|
|
2018-01-09 07:36:02 +00:00
|
|
|
/** Add an array of arrays of JS data to a worksheet */
|
|
|
|
sheet_add_aoa<T>(ws: WorkSheet, data: T[][], opts?: SheetAOAOpts): WorkSheet;
|
|
|
|
sheet_add_aoa(ws: WorkSheet, data: any[][], opts?: SheetAOAOpts): WorkSheet;
|
|
|
|
|
|
|
|
/** Add an array of JS objects to a worksheet */
|
|
|
|
sheet_add_json(ws: WorkSheet, data: any[], opts?: SheetJSONOpts): WorkSheet;
|
|
|
|
sheet_add_json<T>(ws: WorkSheet, data: T[], opts?: SheetJSONOpts): WorkSheet;
|
|
|
|
|
|
|
|
|
2017-06-19 07:14:14 +00:00
|
|
|
consts: XLSX$Consts;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface XLSX$Consts {
|
|
|
|
/* --- Sheet Visibility --- */
|
|
|
|
|
|
|
|
/** Visibility: Visible */
|
|
|
|
SHEET_VISIBLE: 0;
|
|
|
|
|
|
|
|
/** Visibility: Hidden */
|
|
|
|
SHEET_HIDDEN: 1;
|
|
|
|
|
|
|
|
/** Visibility: Very Hidden */
|
|
|
|
SHEET_VERYHIDDEN: 2;
|
2015-06-03 13:34:42 +00:00
|
|
|
}
|
2017-05-16 17:45:35 +00:00
|
|
|
|
|
|
|
/** NODE ONLY! these return Readable Streams */
|
|
|
|
export interface StreamUtils {
|
|
|
|
/** CSV output stream, generate one line at a time */
|
|
|
|
to_csv(sheet: WorkSheet, opts?: Sheet2CSVOpts): any;
|
|
|
|
/** HTML output stream, generate one line at a time */
|
|
|
|
to_html(sheet: WorkSheet, opts?: Sheet2HTMLOpts): any;
|
2018-07-09 03:46:11 +00:00
|
|
|
/** JSON object stream, generate one row at a time */
|
|
|
|
to_json(sheet: WorkSheet, opts?: Sheet2JSONOpts): any;
|
2017-05-16 17:45:35 +00:00
|
|
|
}
|