API Reference
Complete API documentation for xldx
API Reference
Constructor
"code-keyword">new Xldx(data: DataRow[] | SheetsData, options?: XldxOptions)
Creates a new Xldx instance.
Parameters
data- Array of data objects or sheet data structureoptions- Optional configuration object
Methods
createSheet()
createSheet(options: SheetOptions, ...columns: ColumnDefinition[]): this
Creates a new worksheet with specified columns.
setTheme()
setTheme(theme: ColorTheme): this
Sets the color theme for styling.
toBuffer() (node, bun, or deno only)
"code-keyword">async toBuffer(): Promise
Generates Excel file as a Buffer.
toBlob() (Browser only)
"code-keyword">async toBlob(): Promise
Generates Excel file as a Blob.
toUint8Array()
"code-keyword">async toUint8Array(): Promise
Generates Excel file as Uint8Array.
download() (Browser only)
"code-keyword">async download(filename?: string): Promise<"code-keyword">void>
Triggers file download in the browser.
write() (node, bun, or deno only)
"code-keyword">async write(filePath: string): Promise<"code-keyword">void>
Writes Excel file to disk.
getSheetData()
getSheetData(sheet: string | number): SheetDataAPI
Returns an API for manipulating sheet data after creation.
Types
ColumnDefinition
interface ColumnDefinition {
key: string;
header?: string;
width?: number | 'auto';
style?: CellStyle;
patterns?: {
bgColorPattern?: string | PatternFunction;
textPattern?: string | PatternFunction;
};
}
SheetOptions
interface SheetOptions {
name: string;
freezePane?: {
row: number;
column: number;
};
showGridLines?: boolean;
}
Pattern Functions
xldx includes built-in pattern functions:
zebraBg- Alternating row colorsbgColorBasedOnDiff- Background color based on value changestxtColorBasedOnDiff- Text color based on value changes