excelize-wasm
Version:
A pure WebAssembly / Javascript port of Go Excelize library that allow you to write to and read from XLAM / XLSM / XLSX / XLTM / XLTX files
3,772 lines • 145 kB
TypeScript
// Copyright 2022 - 2024 The excelize-wasm Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
// Package excelize providing a set of functions that allow you to write to and
// read from XLAM / XLSM / XLSX / XLTM / XLTX files. Supports reading and
// writing spreadsheet documents generated by Microsoft Excel™ 2007 and later.
// Supports complex components by high compatibility.
//
// Type definitions for excelize-wasm
declare module 'excelize-wasm' {
/**
* AppProperties directly maps the document application properties.
*/
export type AppProperties = {
Application?: string;
ScaleCrop?: boolean;
DocSecurity?: number;
Company?: string;
LinksUpToDate?: boolean;
HyperlinksChanged?: boolean;
AppVersion?: string;
};
/**
* This section defines the currently supported country code types
* enumeration for apply number format.
*/
export enum CultureName {
CultureNameUnknown,
CultureNameEnUS,
CultureNameJaJP,
CultureNameKoKR,
CultureNameZhCN,
CultureNameZhTW,
}
/**
* This section defines the cell value types enumeration.
*/
export enum CellType {
CellTypeUnset,
CellTypeBool,
CellTypeDate,
CellTypeError,
CellTypeFormula,
CellTypeInlineString,
CellTypeNumber,
CellTypeSharedString,
}
/**
* FormControlType is the type of supported form controls.
*/
export enum FormControlType {
FormControlNote,
FormControlButton,
FormControlOptionButton,
FormControlSpinButton,
FormControlCheckBox,
FormControlGroupBox,
FormControlLabel,
FormControlScrollBar,
}
/**
* Options define the options for o`pen and reading spreadsheet.
*
* MaxCalcIterations specifies the maximum iterations for iterative
* calculation, the default value is 0.
*
* Password specifies the password of the spreadsheet in plain text.
*
* RawCellValue specifies if apply the number format for the cell value or get
* the raw value.
*
* UnzipSizeLimit specifies the unzip size limit in bytes on open the
* spreadsheet, this value should be greater than or equal to
* UnzipXMLSizeLimit, the default size limit is 16GB.
*
* UnzipXMLSizeLimit specifies the memory limit on unzipping worksheet and
* shared string table in bytes, worksheet XML will be extracted to system
* temporary directory when the file size is over this value, this value
* should be less than or equal to UnzipSizeLimit, the default value is
* 16MB.
*
* ShortDatePattern specifies the short date number format code. In the
* spreadsheet applications, date formats display date and time serial numbers
* as date values. Date formats that begin with an asterisk (*) respond to
* changes in regional date and time settings that are specified for the
* operating system. Formats without an asterisk are not affected by operating
* system settings. The ShortDatePattern used for specifies apply date formats
* that begin with an asterisk.
*
* LongDatePattern specifies the long date number format code.
*
* LongTimePattern specifies the long time number format code.
*
* CultureInfo specifies the country code for applying built-in language
* number format code these effect by the system's local language settings.
*/
export type Options = {
MaxCalcIterations?: number;
Password?: string;
RawCellValue?: boolean;
UnzipSizeLimit?: number;
UnzipXMLSizeLimit?: number;
ShortDatePattern?: string;
LongDatePattern?: string;
LongTimePattern?: string;
CultureInfo?: CultureName;
};
/**
* Border directly maps the border settings of the cells.
*/
export type Border = {
Type?: string;
Color?: string;
Style?: number;
};
/**
* Fill directly maps the fill settings of the cells.
*/
export type Fill = {
Type?: string;
Pattern?: number;
Color?: string[];
Shading?: number;
};
/**
* Font directly maps the font settings of the fonts.
*/
export type Font = {
Bold?: boolean;
Italic?: boolean;
Underline?: string;
Family?: string;
Size?: number;
Strike?: boolean;
Color?: string;
ColorIndexed?: number;
ColorTheme?: number;
ColorTint?: number;
VertAlign?: string;
};
/**
* Alignment directly maps the alignment settings of the cells.
*/
export type Alignment = {
Horizontal?: string;
Indent?: number;
JustifyLastLine?: boolean;
ReadingOrder?: number;
RelativeIndent?: number;
ShrinkToFit?: boolean;
TextRotation?: number;
Vertical?: string;
WrapText?: boolean;
};
/**
* Protection directly maps the protection settings of the cells.
*/
export type Protection = {
Hidden?: boolean;
Locked?: boolean;
};
/**
* Style directly maps the style settings of the cells.
*/
export type Style = {
Border?: Border[];
Fill?: Fill;
Font?: Font;
Alignment?: Alignment;
Protection?: Protection;
NumFmt?: number;
DecimalPlaces?: number;
CustomNumFmt?: string;
NegRed?: boolean;
};
/**
* Selection directly maps the settings of the worksheet selection.
*/
export type Selection = {
SQRef?: string;
ActiveCell?: string;
Pane?: string;
};
/**
* Panes directly maps the settings of the panes.
*/
export type Panes = {
Freeze?: boolean;
Split?: boolean;
XSplit?: number;
YSplit?: number;
TopLeftCell?: string;
ActivePane?: string;
Selection?: Selection[];
};
/**
* ConditionalFormatOptions directly maps the conditional format settings of
* the cells.
*/
export type ConditionalFormatOptions = {
Type?: string;
AboveAverage?: boolean;
Percent?: boolean;
Format?: number;
Criteria?: string;
Value?: string;
MinType?: string;
MidType?: string;
MaxType?: string;
MinValue?: string;
MidValue?: string;
MaxValue?: string;
MinColor?: string;
MidColor?: string;
MaxColor?: string;
BarColor?: string;
BarBorderColor?: string;
BarDirection?: string;
BarOnly?: boolean;
BarSolid?: boolean;
IconStyle?: string;
ReverseIcons?: boolean;
IconsOnly?: boolean;
StopIfTrue?: boolean;
};
/**
* Shape directly maps the format settings of the shape.
*/
export type Shape = {
Cell: string;
Type?: string;
Macro?: string;
Width?: number;
Height?: number;
Format?: GraphicOptions;
Fill?: Fill;
Line?: ShapeLine;
Paragraph?: RichTextRun[];
};
/**
* SlicerOptions represents the settings of the slicer.
*
* Name specifies the slicer name, should be an existing field name of the
* given table or pivot table, this setting is required.
*
* Cell specifies the left top cell coordinates the position for inserting the
* slicer, this setting is required.
*
* TableSheet specifies the worksheet name of the table or pivot table, this
* setting is required.
*
* TableName specifies the name of the table or pivot table, this setting is
* required.
*
* Caption specifies the caption of the slicer, this setting is optional.
*
* Macro used for set macro for the slicer, the workbook extension should be
* XLSM or XLTM.
*
* Width specifies the width of the slicer, this setting is optional.
*
* Height specifies the height of the slicer, this setting is optional.
*
* DisplayHeader specifies if display header of the slicer, this setting is
* optional, the default setting is display.
*
* ItemDesc specifies descending (Z-A) item sorting, this setting is optional,
* and the default setting is false (represents ascending).
*
* Format specifies the format of the slicer, this setting is optional.
*/
export type SlicerOptions = {
Name: string;
Cell: string;
TableSheet: string;
TableName: string;
Caption?: string;
Macro?: string;
Width?: number;
Height?: number;
DisplayHeader?: boolean;
ItemDesc?: boolean;
Format?: GraphicOptions;
};
/**
* ShapeLine directly maps the line settings of the shape.
*/
export type ShapeLine = {
Color?: string;
Width?: number;
};
/**
* SparklineOptions directly maps the settings of the sparkline.
*/
export type SparklineOptions = {
Location?: string[];
Range?: string[];
Max?: number;
CustMax?: number;
Min?: number;
CustMin?: number;
Type?: string;
Weight?: number;
DateAxis?: boolean;
Markers?: boolean;
High?: boolean;
Low?: boolean;
First?: boolean;
Last?: boolean;
Negative?: boolean;
Axis?: boolean;
Hidden?: boolean;
Reverse?: boolean;
Style?: number;
SeriesColor?: string;
NegativeColor?: string;
MarkersColor?: string;
FirstColor?: string;
LastColor?: string;
HightColor?: string;
LowColor?: string;
EmptyCells?: string;
};
/**
* GraphicOptions directly maps the format settings of the picture.
*/
export type GraphicOptions = {
AltText?: string;
PrintObject?: boolean;
Locked?: boolean;
LockAspectRatio?: boolean;
AutoFit?: boolean;
AutoFitIgnoreAspect?: boolean;
OffsetX?: number;
OffsetY?: number;
ScaleX?: number;
ScaleY?: number;
Hyperlink?: string;
HyperlinkType?: string;
Positioning?: string;
};
/**
* TableOptions directly maps the format settings of the table.
*/
export type TableOptions = {
Range: string;
Name?: string;
StyleName?: string;
ShowFirstColumn?: boolean;
ShowLastColumn?: boolean;
ShowRowStripes?: boolean;
ShowColumnStripes?: boolean;
};
/**
* AutoFilterOptions directly maps the auto filter settings.
*/
export type AutoFilterOptions = {
Column?: string;
Expression?: string;
};
/**
* FormControl directly maps the form controls information.
*/
export type FormControl = {
Cell: string;
Macro?: string;
Width?: number;
Height?: number;
Checked?: boolean;
CurrentVal?: number;
MinVal?: number;
MaxVal?: number;
IncChange?: number;
PageChange?: number;
Horizontally?: boolean;
CellLink?: string;
Text?: string;
Paragraph?: RichTextRun[];
Type?: FormControlType;
Format?: GraphicOptions;
};
/*
* ChartNumFmt directly maps the number format settings of the chart.
*/
export type ChartNumFmt = {
CustomNumFmt?: string;
SourceLinked?: boolean;
};
/**
* ChartAxis directly maps the format settings of the chart axis.
*/
export type ChartAxis = {
None?: boolean;
MajorGridLines?: boolean;
MinorGridLines?: boolean;
MajorUnit?: number;
TickLabelPosition?: ChartTickLabelPositionType;
TickLabelSkip?: number;
ReverseOrder?: boolean;
Secondary?: boolean;
Maximum?: number;
Minimum?: number;
Font?: Font;
LogBase?: number;
NumFmt?: ChartNumFmt;
Title?: RichTextRun[];
};
/**
* ChartDimension directly maps the dimension of the chart.
*/
export type ChartDimension = {
Width?: number;
Height?: number;
};
/**
* ChartPlotArea directly maps the format settings of the plot area.
*/
export type ChartPlotArea = {
SecondPlotValues?: number;
ShowBubbleSize?: boolean;
ShowCatName?: boolean;
ShowLeaderLines?: boolean;
ShowPercent?: boolean;
ShowSerName?: boolean;
ShowVal?: boolean;
Fill?: Fill;
NumFmt?: ChartNumFmt;
};
/**
* ChartLineType defines the currently supported chart line types enumeration.
*/
export enum ChartLineType {
ChartLineUnset,
ChartLineSolid,
ChartLineNone,
ChartLineAutomatic,
}
/**
* ChartType defines the currently supported chart types enumeration.
*/
export enum ChartType {
Area,
AreaStacked,
AreaPercentStacked,
Area3D,
Area3DStacked,
Area3DPercentStacked,
Bar,
BarStacked,
BarPercentStacked,
Bar3DClustered,
Bar3DStacked,
Bar3DPercentStacked,
Bar3DConeClustered,
Bar3DConeStacked,
Bar3DConePercentStacked,
Bar3DPyramidClustered,
Bar3DPyramidStacked,
Bar3DPyramidPercentStacked,
Bar3DCylinderClustered,
Bar3DCylinderStacked,
Bar3DCylinderPercentStacked,
Col,
ColStacked,
ColPercentStacked,
Col3D,
Col3DClustered,
Col3DStacked,
Col3DPercentStacked,
Col3DCone,
Col3DConeClustered,
Col3DConeStacked,
Col3DConePercentStacked,
Col3DPyramid,
Col3DPyramidClustered,
Col3DPyramidStacked,
Col3DPyramidPercentStacked,
Col3DCylinder,
Col3DCylinderClustered,
Col3DCylinderStacked,
Col3DCylinderPercentStacked,
Doughnut,
Line,
Line3D,
Pie,
Pie3D,
PieOfPie,
BarOfPie,
Radar,
Scatter,
Surface3D,
WireframeSurface3D,
Contour,
WireframeContour,
Bubble,
Bubble3D,
}
/**
* ChartDataLabelPositionType is the type of chart data labels position.
*/
export enum ChartDataLabelPositionType {
ChartDataLabelsPositionUnset,
ChartDataLabelsPositionBestFit,
ChartDataLabelsPositionBelow,
ChartDataLabelsPositionCenter,
ChartDataLabelsPositionInsideBase,
ChartDataLabelsPositionInsideEnd,
ChartDataLabelsPositionLeft,
ChartDataLabelsPositionOutsideEnd,
ChartDataLabelsPositionRight,
ChartDataLabelsPositionAbove,
}
/**
* ChartTickLabelPositionType is the type of supported chart tick label
* position types.
*/
export enum ChartTickLabelPositionType {
ChartTickLabelNextToAxis,
ChartTickLabelHigh,
ChartTickLabelLow,
ChartTickLabelNone,
}
/**
* Chart directly maps the format settings of the chart.
*/
export type Chart = {
Type: ChartType;
Series?: ChartSeries[];
Format?: GraphicOptions;
Dimension?: ChartDimension;
Legend?: ChartLegend;
Title?: RichTextRun[];
VaryColors?: boolean;
XAxis?: ChartAxis;
YAxis?: ChartAxis;
PlotArea?: ChartPlotArea;
Fill?: Fill;
Border?: ChartLine;
ShowBlanksAs?: string;
BubbleSize?: number;
HoleSize?: number;
};
/**
* ChartLegend directly maps the format settings of the chart legend.
*/
export type ChartLegend = {
Position?: string
ShowLegendKey?: boolean;
};
/**
* ChartMarker directly maps the format settings of the chart marker.
*/
export type ChartMarker = {
Fill?: Fill;
Symbol?: string;
Size?: number;
};
/**
* ChartLine directly maps the format settings of the chart line.
*/
export type ChartLine = {
Type?: ChartLineType;
Smooth?: boolean;
Width?: number;
};
/**
* ChartSeries directly maps the format settings of the chart series.
*/
export type ChartSeries = {
Name?: string;
Categories?: string;
Values?: string;
Sizes?: string;
Fill?: Fill;
Line?: ChartLine;
Marker?: ChartMarker;
DataLabelPosition?: ChartDataLabelPositionType;
};
/**
* PivotTableOptions directly maps the format settings of the pivot table.
*
* PivotTableStyleName: The built-in pivot table style names
*
* PivotStyleLight1 - PivotStyleLight28
* PivotStyleMedium1 - PivotStyleMedium28
* PivotStyleDark1 - PivotStyleDark28
*/
export type PivotTableOptions = {
DataRange?: string;
PivotTableRange?: string;
Name?: string;
Rows?: PivotTableField[];
Columns?: PivotTableField[];
Data?: PivotTableField[];
Filter?: PivotTableField[];
RowGrandTotals?: boolean;
ColGrandTotals?: boolean;
ShowDrill?: boolean;
UseAutoFormatting?: boolean;
PageOverThenDown?: boolean;
MergeItem?: boolean;
ClassicLayout?: boolean;
CompactData ?: boolean;
ShowError?: boolean;
ShowRowHeaders?: boolean;
ShowColHeaders?: boolean;
ShowRowStripes?: boolean;
ShowColStripes?: boolean;
ShowLastColumn?: boolean;
FieldPrintTitles?: boolean;
ItemPrintTitles?: boolean;
PivotTableStyleName?: string;
};
/**
* PivotTableField directly maps the field settings of the pivot table.
*
* Name specifies the name of the data field. Maximum 255 characters
* are allowed in data field name, excess characters will be truncated.
*
* Subtotal specifies the aggregation function that applies to this data
* field. The default value is sum. The possible values for this attribute
* are:
*
* Average
* Count
* CountNums
* Max
* Min
* Product
* StdDev
* StdDevp
* Sum
* Var
* Varp
*
* NumFmt specifies the number format ID of the data field, this filed only
* accepts built-in number format ID and does not support custom number format
* expression currently.
*/
export type PivotTableField = {
Compact?: boolean;
Data?: string;
Name?: string;
Outline?: boolean;
ShowAll?: boolean;
InsertBlankRow?: boolean;
Subtotal?: string;
DefaultSubtotal?: boolean;
NumFmt?: number;
};
/**
* Comment directly maps the comment information.
*/
export type Comment = {
Author?: string;
AuthorID?: number;
Cell: string;
Text?: string;
Width?: number;
Height?: number;
Paragraph?: RichTextRun[];
};
/**
* PictureInsertType defines the type of the picture has been inserted into
* the worksheet.
*/
export enum PictureInsertType {
PictureInsertTypePlaceOverCells,
PictureInsertTypePlaceInCell,
PictureInsertTypeDISPIMG,
}
/**
* Picture maps the format settings of the picture.
*/
export type Picture = {
Extension: string;
File: Uint8Array;
Format: GraphicOptions;
InsertType: PictureInsertType;
};
/**
* DataValidation directly maps the a single item of data validation defined
* on a range of the worksheet.
*/
export type DataValidation = {
AllowBlank?: boolean;
Error?: string;
ErrorStyle?: string;
ErrorTitle?: string;
Operator?: string
Prompt?: string;
PromptTitle?: string;
ShowDropDown?: boolean;
ShowErrorMessage?: boolean;
ShowInputMessage?: boolean;
Sqref?: string;
Type?: string;
Formula1?: string;
Formula2?: string;
};
/**
* RichTextRun directly maps the settings of the rich text run.
*/
export type RichTextRun = {
Font?: Font;
Text?: string;
};
/**
* FormulaOptions can be passed to SetCellFormula to use other formula types.
*/
export type FormulaOptions = {
Ref?: string;
Type?: string;
};
/**
* HyperlinkOpts can be passed to SetCellHyperlink to set optional hyperlink
* attributes (e.g. display value).
*/
export type HyperlinkOpts = {
Display?: string;
Tooltip?: string;
};
/**
* SheetProtectionOptions directly maps the settings of worksheet protection.
*/
export type SheetProtectionOptions = {
AlgorithmName?: string;
AutoFilter?: boolean;
DeleteColumns?: boolean;
DeleteRows?: boolean;
EditObjects?: boolean;
EditScenarios?: boolean;
FormatCells?: boolean;
FormatColumns?: boolean;
FormatRows?: boolean;
InsertColumns?: boolean;
InsertHyperlinks?: boolean;
InsertRows?: boolean;
Password?: string;
PivotTables?: boolean;
SelectLockedCells?: boolean;
SelectUnlockedCells?: boolean;
Sort?: boolean;
};
/**
* DefinedName directly maps the name for a cell or cell range on a
* worksheet.
*/
export type DefinedName = {
Name?: string;
Comment?: string;
RefersTo?: string;
Scope?: string;
};
/**
* DocProperties directly maps the document core properties.
*/
export type DocProperties = {
Category?: string;
ContentStatus?: string;
Created?: string;
Creator?: string;
Description?: string;
Identifier?: string;
Keywords?: string;
LastModifiedBy?: string;
Modified?: string;
Revision?: string;
Subject?: string;
Title?: string;
Language?: string;
Version?: string;
};
/**
* HeaderFooterOptions directly maps the settings of header and footer.
*/
export type HeaderFooterOptions = {
AlignWithMargins?: boolean;
DifferentFirst?: boolean;
DifferentOddEven?: boolean;
ScaleWithDoc?: boolean;
OddHeader?: string;
OddFooter?: string;
EvenHeader?: string;
EvenFooter?: string;
FirstHeader?: string;
FirstFooter?: string;
};
/**
* MergeCell define a merged cell data.
*/
export interface MergeCell {
/**
* GetCellValue returns merged cell value.
*/
GetCellValue: () => string;
/**
* GetStartAxis returns the top left cell reference of merged range, for
* example: "C2".
*/
GetStartAxis: () => string;
/**
* GetEndAxis returns the bottom right cell reference of merged range, for
* example: "D4".
*/
GetEndAxis: () => string;
}
/**
* PageLayoutOptions directly maps the settings of page layout.
*/
export type PageLayoutOptions = {
// Size defines the paper size of the worksheet.
Size?: number;
// Orientation defines the orientation of page layout for a worksheet.
Orientation?: string;
// FirstPageNumber specified the first printed page number. If no value is
// specified, then 'automatic' is assumed.
FirstPageNumber?: number;
// AdjustTo defines the print scaling. This attribute is restricted to
// value ranging from 10 (10%) to 400 (400%). This setting is overridden
// when fitToWidth and/or fitToHeight are in use.
AdjustTo?: number;
// FitToHeight specified the number of vertical pages to fit on.
FitToHeight?: number;
// FitToWidth specified the number of horizontal pages to fit on.
FitToWidth?: number;
// BlackAndWhite specified print black and white.
BlackAndWhite?: boolean;
};
/**
* PageLayoutMarginsOptions directly maps the settings of page layout margins.
*/
export type PageLayoutMarginsOptions = {
Bottom?: number;
Footer?: number;
Header?: number;
Left?: number;
Right?: number;
Top?: number;
Horizontally?: boolean;
Vertically?: boolean;
};
/*
* SheetPropsOptions directly maps the settings of sheet view.
*/
export type SheetPropsOptions = {
// Specifies a stable name of the sheet, which should not change over time,
// and does not change from user input. This name should be used by code
// to reference a particular sheet.
CodeName?: string;
// EnableFormatConditionsCalculation indicating whether the conditional
// formatting calculations shall be evaluated. If set to false, then the
// min/max values of color scales or data bars or threshold values in Top N
// rules shall not be updated. Essentially the conditional
// formatting "calc" is off.
EnableFormatConditionsCalculation?: boolean;
// Published indicating whether the worksheet is published.
Published?: boolean;
// AutoPageBreaks indicating whether the sheet displays Automatic Page
// Breaks.
AutoPageBreaks?: boolean;
// FitToPage indicating whether the Fit to Page print option is enabled.
FitToPage?: boolean;
// TabColorIndexed represents the indexed color value.
TabColorIndexed?: number;
// TabColorRGB represents the standard Alpha Red Green Blue color value.
TabColorRGB?: string;
// TabColorTheme represents the zero-based index into the collection,
// referencing a particular value expressed in the Theme part.
TabColorTheme?: number;
// TabColorTint specifies the tint value applied to the color.
TabColorTint?: number;
// OutlineSummaryBelow indicating whether summary rows appear below detail
// in an outline, when applying an outline.
OutlineSummaryBelow?: boolean;
// OutlineSummaryRight indicating whether summary columns appear to the
// right of detail in an outline, when applying an outline.
OutlineSummaryRight?: boolean;
// BaseColWidth specifies the number of characters of the maximum digit
// width of the normal style's font. This value does not include margin
// padding or extra padding for grid lines. It is only the number of
// characters.
BaseColWidth?: number;
// DefaultColWidth specifies the default column width measured as the
// number of characters of the maximum digit width of the normal style's
// font.
DefaultColWidth?: number;
// DefaultRowHeight specifies the default row height measured in point
// size. Optimization so we don't have to write the height on all rows.
// This can be written out if most rows have custom height, to achieve the
// optimization.
DefaultRowHeight?: number;
// CustomHeight specifies the custom height.
CustomHeight?: boolean;
// ZeroHeight specifies if rows are hidden.
ZeroHeight?: boolean;
// ThickTop specifies if rows have a thick top border by default.
ThickTop?: boolean;
// ThickBottom specifies if rows have a thick bottom border by default.
ThickBottom?: boolean;
};
export type ViewOptions = {
// DefaultGridColor indicating that the consuming application should use
// the default grid lines color(system dependent). Overrides any color
// specified in colorId.
DefaultGridColor?: boolean;
// RightToLeft indicating whether the sheet is in 'right to left' display
// mode. When in this mode, Column A is on the far right, Column B; is one
// column left of Column A, and so on. Also, information in cells is
// displayed in the Right to Left format.
RightToLeft?: boolean;
// ShowFormulas indicating whether this sheet should display formulas.
ShowFormulas?: boolean;
// ShowGridLines indicating whether this sheet should display grid lines.
ShowGridLines?: boolean;
// ShowRowColHeaders indicating whether the sheet should display row and
// column headings.
ShowRowColHeaders?: boolean;
// ShowRuler indicating this sheet should display ruler.
ShowRuler?: boolean;
// ShowZeros indicating whether to "show a zero in cells that have zero
// value". When using a formula to reference another cell which is empty,
// the referenced value becomes 0 when the flag is true. (Default setting
// is true.)
ShowZeros?: boolean;
// TopLeftCell specifies a location of the top left visible cell Location
// of the top left visible cell in the bottom right pane (when in
// Left-to-Right mode).
TopLeftCell: string;
// View indicating how sheet is displayed, by default it uses empty string
// available options: normal, pageLayout, pageBreakPreview
View: string;
// ZoomScale specifies a window zoom magnification for current view
// representing percent values. This attribute is restricted to values
// ranging from 10 to 400. Horizontal & Vertical scale together.
ZoomScale?: number;
};
/**
* WorkbookPropsOptions directly maps the settings of workbook proprieties.
*/
export type WorkbookPropsOptions = {
Date1904?: boolean;
FilterPrivacy?: boolean;
CodeName?: string;
};
/**
* WorkbookProtectionOptions directly maps the settings of workbook
* protection.
*/
export type WorkbookProtectionOptions = {
AlgorithmName?: string;
Password?: string;
LockStructure?: boolean;
LockWindows?: boolean;
};
/**
* CellNameToCoordinates converts alphanumeric cell name to [X, Y]
* coordinates or returns an error.
* @param cell The cell reference
*/
export function CellNameToCoordinates(cell: string): { col: number, row: number, error: string | null }
/**
* ColumnNameToNumber provides a function to convert Excel sheet column name
* (case-insensitive) to int. The function returns an error if column name
* incorrect.
* @param name The column name
*/
export function ColumnNameToNumber(name: string): { col: number, error: string | null }
/**
* ColumnNumberToName provides a function to convert the integer to Excel
* sheet column title.
* @param num The column name
*/
export function ColumnNumberToName(num: number): { col: string, error: string | null }
/**
* CoordinatesToCellName converts [X, Y] coordinates to alpha-numeric cell
* name or returns an error.
* @param col The column number
* @param row The row number
* @param abs Specifies the absolute cell references
*/
export function CoordinatesToCellName(col: number, row: number, abs?: boolean): { cell: string, error: string | null }
/**
* HSLToRGB converts an HSL triple to a RGB triple.
* @param h Hue
* @param s Saturation
* @param l Lightness
*/
export function HSLToRGB(h: number, s: number, l: number): { r: number, g: number, b: number, error: string | null }
/**
* JoinCellName joins cell name from column name and row number.
* @param col The column name
* @param row The row number
*/
export function JoinCellName(col: string, row: number): { cell: string, error: string | null }
/**
* RGBToHSL converts an RGB triple to a HSL triple.
* @param r Red
* @param g Green
* @param b Blue
*/
export function RGBToHSL(r: number, g: number, b: number): { h: number, s: number, l: number, error: string | null }
/**
* SplitCellName splits cell name to column name and row number.
* @param cell The cell reference
*/
export function SplitCellName(cell: string): { col: string, row: number, error: string | null }
/**
* ThemeColor applied the color with tint value.
* @param baseColor Base color in hex format
* @param tint A mixture of a color with white
*/
export function ThemeColor(baseColor: string, tint: number): { color: string, error: string | null }
/**
* NewFile provides a function to create new file by default template.
* @param opts The options for open and reading spreadsheet
*/
export function NewFile(opts?: Options): NewFile;
/**
* OpenReader read data stream from buffer and return a populated spreadsheet
* file.
* @param r The contents buffer of the file
* @param opts The options for open and reading spreadsheet
*/
export function OpenReader(r: Uint8Array, opts?: Options): NewFile;
/**
* @constructor
*/
export class NewFile {
/**
* AddChart provides the method to add chart in a sheet by given chart
* format set (such as offset, scale, aspect ratio setting and print
* settings) and properties set. For example, create 3D clustered column
* chart with data Sheet1!$E$1:$L$15:
*
* ```typescript
* const { init } = require('excelize-wasm');
* const fs = require('fs');
*
* init('./node_modules/excelize-wasm/excelize.wasm.gz').then((excelize) => {
* const f = excelize.NewFile();
* if (f.error) {
* console.log(f.error);
* return;
* }
* [
* [null, 'Apple', 'Orange', 'Pear'],
* ['Small', 2, 3, 3],
* ['Normal', 5, 2, 4],
* ['Large', 6, 7, 8],
* ].forEach((row, idx) => {
* const ret1 = excelize.CoordinatesToCellName(1, idx + 1);
* if (ret1.error) {
* console.log(ret1.error);
* return;
* }
* const res2 = f.SetSheetRow('Sheet1', ret1.cell, row);
* if (res2.error) {
* console.log(res2.error);
* return;
* }
* });
* const ret3 = f.AddChart('Sheet1', 'E1', {
* Type: excelize.Col3DClustered,
* Series: [
* {
* Name: 'Sheet1!$A$2',
* Categories: 'Sheet1!$B$1:$D$1',
* Values: 'Sheet1!$B$2:$D$2',
* },
* {
* Name: 'Sheet1!$A$3',
* Categories: 'Sheet1!$B$1:$D$1',
* Values: 'Sheet1!$B$3:$D$3',
* },
* {
* Name: 'Sheet1!$A$4',
* Categories: 'Sheet1!$B$1:$D$1',
* Values: 'Sheet1!$B$4:$D$4',
* },
* ],
* Title: [{
* Text: 'Fruit 3D Clustered Column Chart',
* }],
* });
* if (ret3.error) {
* console.log(ret3.error);
* return;
* }
* // Save spreadsheet by the given path.
* const { buffer, error } = f.WriteToBuffer();
* if (error) {
* console.log(error);
* return;
* }
* fs.writeFile('Book1.xlsx', buffer, 'binary', (error) => {
* if (error) {
* console.log(error);
* }
* });
* });
* ```
*
* The following shows the type of chart supported by excelize:
*
* ID | Enumeration | Chart
* ----+-----------------------------+------------------------------
* 0 | Area | 2D area chart
* 1 | AreaStacked | 2D stacked area chart
* 2 | AreaPercentStacked | 2D 100% stacked area chart
* 3 | Area3D | 3D area chart
* 4 | Area3DStacked | 3D stacked area chart
* 5 | Area3DPercentStacked | 3D 100% stacked area chart
* 6 | Bar | 2D clustered bar chart
* 7 | BarStacked | 2D stacked bar chart
* 8 | BarPercentStacked | 2D 100% stacked bar chart
* 9 | Bar3DClustered | 3D clustered bar chart
* 10 | Bar3DStacked | 3D stacked bar chart
* 11 | Bar3DPercentStacked | 3D 100% stacked bar chart
* 12 | Bar3DConeClustered | 3D cone clustered bar chart
* 13 | Bar3DConeStacked | 3D cone stacked bar chart
* 14 | Bar3DConePercentStacked | 3D cone percent bar chart
* 15 | Bar3DPyramidClustered | 3D pyramid clustered bar chart
* 16 | Bar3DPyramidStacked | 3D pyramid stacked bar chart
* 17 | Bar3DPyramidPercentStacked | 3D pyramid percent stacked bar chart
* 18 | Bar3DCylinderClustered | 3D cylinder clustered bar chart
* 19 | Bar3DCylinderStacked | 3D cylinder stacked bar chart
* 20 | Bar3DCylinderPercentStacked | 3D cylinder percent stacked bar chart
* 21 | Col | 2D clustered column chart
* 22 | ColStacked | 2D stacked column chart
* 23 | ColPercentStacked | 2D 100% stacked column chart
* 24 | Col3DClustered | 3D clustered column chart
* 25 | Col3D | 3D column chart
* 26 | Col3DStacked | 3D stacked column chart
* 27 | Col3DPercentStacked | 3D 100% stacked column chart
* 28 | Col3DCone | 3D cone column chart
* 29 | Col3DConeClustered | 3D cone clustered column chart
* 30 | Col3DConeStacked | 3D cone stacked column chart
* 31 | Col3DConePercentStacked | 3D cone percent stacked column chart
* 32 | Col3DPyramid | 3D pyramid column chart
* 33 | Col3DPyramidClustered | 3D pyramid clustered column chart
* 34 | Col3DPyramidStacked | 3D pyramid stacked column chart
* 35 | Col3DPyramidPercentStacked | 3D pyramid percent stacked column chart
* 36 | Col3DCylinder | 3D cylinder column chart
* 37 | Col3DCylinderClustered | 3D cylinder clustered column chart
* 38 | Col3DCylinderStacked | 3D cylinder stacked column chart
* 39 | Col3DCylinderPercentStacked | 3D cylinder percent stacked column chart
* 40 | Doughnut | doughnut chart
* 41 | Line | line chart
* 42 | Line3D | 3D line chart
* 43 | Pie | pie chart
* 44 | Pie3D | 3D pie chart
* 45 | PieOfPie | pie of pie chart
* 46 | BarOfPie | bar of pie chart
* 47 | Radar | radar chart
* 48 | Scatter | scatter chart
* 49 | Surface3D | 3D surface chart
* 50 | WireframeSurface3D | 3D wireframe surface chart
* 51 | Contour | contour chart
* 52 | WireframeContour | wireframe contour chart
* 53 | Bubble | bubble chart
* 54 | Bubble3D | 3D bubble chart
*
* In Excel a chart series is a collection of information that defines which
* data is plotted such as values, axis labels and formatting.
*
* The series options that can be set are:
*
* Name
* Categories
* Values
* Fill
* Line
* Marker
* DataLabelPosition
*
* Name: Set the name for the series. The name is displayed in the chart
* legend and in the formula bar. The 'Name' property is optional and if it
* isn't supplied it will default to Series 1..n. The name can also be a
* formula such as Sheet1!$A$1
*
* Categories: This sets the chart category labels. The category is more or
* less the same as the X axis. In most chart types the 'Categories'
* property is optional and the chart will just assume a sequential series
* from 1..n.
*
* Values: This is the most important property of a series and is the only
* mandatory option for every chart object. This option links the chart with
* the worksheet data that it displays.
*
* Sizes: This sets the bubble size in a data series. The 'Sizes' property
* is optional and the default value was same with 'Values'.
*
* Fill: This set the format for the data series fill. The 'Fill' property
* is optional.
*
* Line: This sets the line format of the line chart. The 'Line' property is
* optional and if it isn't supplied it will default style. The options that
* can be set are width and color. The range of width is 0.25pt - 999pt. If
* the value of width is outside the range, the default width of the line is
* 2pt.
*
* Marker: This sets the marker of the line chart and scatter chart. The
* range of optional field 'Size' is 2-72 (default value is 5). The
* enumeration value of optional field 'Symbol' are (default value is
* 'auto'):
*
* circle
* dash
* diamond
* dot
* none
* picture
* plus
* square
* star
* triangle
* x
* auto
*
* DataLabelPosition: This sets the position of the chart series data label.
*
* Set properties of the chart legend. The options that can be set are:
*
* Position
* ShowLegendKey
*
* Position: Set the position of the chart legend. The default legend
* position is bottom. The available positions are:
*
* none
* top
* bottom
* left
* right
* top_right
*
* ShowLegendKey: Set the legend keys shall be shown in data labels. The
* default value is false.
*
* Set properties of the chart title. The properties that can be set are:
*
* Title
*
* Title: Set the name (title) for the chart. The name is displayed above
* the chart. The name can also be a formula such as Sheet1!$A$1 or a list
* with a sheet name. The name property is optional. The default is to have
* no chart title.
*
* Specifies how blank cells are plotted on the chart by 'ShowBlanksAs'. The
* default value is gap. The options that can be set are:
*
* gap
* span
* zero
*
* gap: Specifies that blank values shall be left as a gap.
*
* span: Specifies that blank values shall be spanned with a line.
*
* zero: Specifies that blank values shall be treated as zero.
*
* Specifies that each data marker in the series has a different color by
* 'VaryColors'. The default value is true.
*
* Set chart offset, scale, aspect ratio setting and print settings by
* 'Format', same as function 'AddPicture'.
*
* Set the position of the chart plot area by 'PlotArea'. The properties
* that can be set are:
*
* SecondPlotValues
* ShowBubbleSize
* ShowCatName
* ShowLeaderLines
* ShowPercent
* ShowSerName
* ShowVal
* NumFmt
*
* SecondPlotValues: Specifies the values in second plot for the 'pieOfPie'
* and 'barOfPie' chart.
*
* ShowBubbleSize: Specifies the bubble size shall be shown in a data label.
* The 'ShowBubbleSize' property is optional. The default value is false.
*
* ShowCatName: Specifies that the category name shall be shown in the data
* label. The 'ShowCatName' property is optional. The default value is true.
*
* ShowLeaderLines: Specifies leader lines shall be shown for data labels.
* The 'ShowLeaderLines' property is optional. The default value is false.
*
* ShowPercent: Specifies that the percentage shall be shown in a data
* label. The 'ShowPercent' property is optional. The default value is
* false.
*
* ShowSerName: Specifies that the series name shall be shown in a data
* label. The 'ShowSerName' property is optional. The default value is
* false.
*
* ShowVal: Specifies that the value shall be shown in a data label.
* The 'ShowVal' property is optional. The default value is false.
*
* NumFmt: Specifies that if linked to source and set custom number format
* code for data labels. The 'NumFmt' property is optional. The default
* format code is 'General'.
*
* Set the primary horizontal and vertical axis options by 'XAxis' and
* 'YAxis'. The properties of 'XAxis' that can be set are:
*
* None
* MajorGridLines
* MinorGridLines
* TickLabelSkip
* ReverseOrder
* Maximum
* Minimum
* Font
* NumFmt
* Title
*
* The properties of 'YAxis' that can be set are:
*
* None
* MajorGridLines
* MinorGridLines
* MajorUnit
* Secondary
* ReverseOrder
* Maximum
* Minimum
* Font
* LogBase
* NumFmt
* Title
*
* None: Disable axes.
*
* MajorGridLines: Specifies major grid lines.
*
* MinorGridLines: Specifies minor grid lines.
*
* MajorUnit: Specifies the distance between major ticks. Shall contain a
* positive floating-point number. The 'MajorUnit' property is optional. The
* default value is auto.
*
* Secondary: Specifies the current series vertical axis as the secondary
* axis, this only works for the second and later chart in the combo chart.
* The default value is false.
*
* TickLabelSkip: Specifies how many tick labels to skip between label that
* is drawn. The 'TickLabelSkip' property is optional. The default value is
* auto.
*
* ReverseOrder: Specifies that the categories or values on reverse order
* (orientation of the chart). The 'ReverseOrder' property is optional. The
* default value is false.
*
* Maximum: Specifies that the fixed maximum, 0 is auto. The 'Maximum'
* property is optional. The default value is auto.
*
* Minimum: Specifies that the fixed minimum, 0 is auto. The 'Minimum'
* property is optional. The default value is auto.
*
* Font: Specifies that the font of the horizontal and vertical axis. The
* properties of font that can be set are:
*
* Bold
* Italic
* Underline
* Family
* Size
* Strike
* Color
* VertAlign
*
* LogBase: Specifies logarithmic scale base number of the vertical axis.
*
* NumFmt: Specifies that if linked to source and set custom number format
* code for axis. The 'NumFmt' property is optional. The default format code
* is 'General'.
*
* Title: Specifies that the primary horizontal or vertical axis title and
* resize chart. The 'Title' property is optional.
*
* Set chart size by 'Dimension' property. The 'Dimension' property is
* optional. The default width is 480, and height is 260.
*
* Set the bubble size in all data series for the bubble chart or 3D bubble
* chart by 'BubbleSizes' property. The 'BubbleSizes' property is optional.
* The default width is 100, and the value should be great than 0 and less
* or equal than 300.
*
* Set the doughnut hole size in all data series for the doughnut chart by
* 'HoleSize' property. The 'HoleSize' property is optional. The default
* width is 75, and the value should be great than 0 and less or equal than
* 90.
*
* combo: Specifies the create a chart that combines two or more chart types
* in a single chart. For example, create a clustered column - line chart
* with data Sheet1!$E$1:$L$15:
*
* ```typescript
* const { init } = require('excelize-wasm');
* const fs = require('fs');
*
* init('./node_modules/excelize-wasm/excelize.wasm.gz').then((excelize) => {
* const f = excelize.NewFile();
* if (f.error) {
* console.log(f.error);
* return;
* }
* [
* [null, 'Apple', 'Orange', 'Pear'],
* ['Small', 2, 3, 3],
* ['Normal', 5, 2, 4],
* ['Large', 6, 7, 8],
* ].forEach((row, idx) => {
* const ret1 = excelize.CoordinatesToCellName(1, idx + 1);
* if (ret1.error) {
* console.log(ret1.error);
* return;
* }
* const res2 = f.SetSheetRow('Sheet1', ret1.cell, row);
* if (res2.error) {
* console.log(res2.error);
* return;
* }
* });
* const ret3 = f.AddChart('Sheet1', 'E1', {
* Type: excelize.Col,
* Series: [
* {
* Name: 'Sheet1!$A$2',
* Categories: 'Sheet1!$B$1:$D$1',
* Values: 'Sheet1!$B$2:$D$2',
* },
* ],
* Format: {
* ScaleX: 1,
* ScaleY: 1,
* OffsetX: 15,
* OffsetY: 10,
* PrintObject: true,
* LockAspectRatio: false,
* Locked: false,
* },
* Title: [{
* Text: 'Clustered Column - Line Chart',
* }],
* Legend: {
* Position: 'left',
* ShowLegendKey: false,
* },
* PlotArea: {
* ShowCatName: false,
* ShowLeaderLines: false,
* ShowPercent: true,
* ShowSerName: true,
* ShowVal: true,
* },
* }, {
* Type: excelize.Line,
* Series: [
* {
* Name: 'Sheet1!$A$4',
* Categories: 'Sheet1!$B$1:$D$1',
* Values: 'Sheet1!$B$4:$D$4',
* Marker: {
* Symbol: 'none',
* Size: 10,
* },
* },
* ],
* Format: {
* ScaleX: 1,
* ScaleY: 1,
* OffsetX: 15,
* OffsetY: 10,
* PrintObject: true,
* LockAspectRatio: false,
* Locked: false,
* },
* Legend: {
* Position: 'right',
* ShowLegendKey: false,
* },
* PlotArea: {
* ShowCatName: false,
* ShowLeaderLines: false,
* ShowPercent: true,
* ShowSerName: true,
* ShowVal: true,
* },
* });
* if (ret3.error) {
* console.log(ret3.error);
* return;
* }
* // Save spreadsheet by the given path.
* const { buffer, error } = f.WriteToBuffer();
* if (error) {
* console.log(error);
* return;
* }
* fs.writeFile('Book1.xlsx', buffer, 'binary', (error) => {
* if (error) {
* console.log(error);
* }
* });
* });
* ```
*
* @param sheet The worksheet name
* @param cell The cell reference
* @param chart The chart options
* @param combo Specifies the create a chart that combines two or more
* chart types in a single chart
*/
AddChart(sheet: string, cell: string, chart: Chart, combo?: Chart): { error: string | null }
/**
* AddChartSheet provides the method to create a chartsheet by given chart
* format set (such as offset, scale, aspect ratio setting and print
* settings) and properties set. In Excel a chartsheet is a worksheet that
* only contains a chart.
* @param sheet The worksheet name
* @param chart The chart options
* @param combo Specifies the create a chart that combines two or more
* chart types in a single chart
*/
AddChartSheet(sheet: string, chart: Chart, combo?: Chart): { error: string | null }
/**
* AddComment provides the method to add comments in a sheet by giving the
* worksheet name, cell reference, and format set (such as author and text).
* Note that the maximum author name length is 255 and the max text length
* is 32512. For example, add a rich-text comment with a specified comments
* box size in Sheet1!A5:
*
* ```typescript
* const { error } = f.AddComment('Sheet1', {
* Cell: 'A5',
* Author: 'Excelize',
* Height: 40,
* Width: 180,
* Paragraph: [
* {
* Font: {
* Bold: true,
* },
* Text: 'Excelize: ',
* },
* {
* Text: 'This is a comment.',
* },
* ],
* });
* ```
*
* @param sheet The worksheet name
* @param comment The comment options
*/
AddComment(sheet: string, comment: Comment): { error: string | null }
/**
* AddDataValidation provides set data validation on a range of the worksheet
* by given data validation object and worksheet name.
* @param sheet The worksheet name
* @param dv The data validation rules
*/
AddDataValidation(sheet: string, dv: DataValidation): { error: string | null }
/**
* AddPictureFromBytes provides the method to add picture in a sheet by given
* picture format set (such as offset, scale, aspect ratio setting and print
* settings), file base name, extension name and file bytes, supported image
* types: EMF, EMZ, GIF, JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ. Note
* that this function only supports adding pictures placed over the cells
* currently, and doesn't support adding pictures placed in cells or
* creating the Kingsoft WPS Office embedded image cells.
*
* The optional parameter "AltText" is used to add alternative text to a
* graph object.
*
* The optional parameter "PrintObject" indicates whether the graph object
* is printed when the worksheet is printed, the default value of that is
* 'true'.
*
* The optional parameter "Locked" indicates whether lock the graph object.
* Locking an object has no effect unless the sheet is protected.
*
* The optional parameter "LockAspectRatio" indicates whether lock aspect
* ratio for the graph object, the default value of that is 'false'.
*
* The optional parameter "AutoFit" specifies if you make graph object size
* auto-fits the cell, the default value of that is 'false'.
*
* The optional parameter "AutoFitIgnoreAspect" specifies if fill the cell
* with the image and ignore its aspect ratio, the default value of that is
* 'false'. This option only works when the "AutoFit" is enabled.
*
* The optional parameter "OffsetX" specifies the horizontal offset of the
* graph object with the cell, the default value of that is 0.
*
* The optional parameter "OffsetY" specifies the vertical offset of the
* graph object with the cell, the default value of that is 0.
*
* The optional parameter "ScaleX" specifies the horizontal scale of graph
* object, the default value of that is 1.0 which presents 100%.
*
* The optional parameter "ScaleY" specifies the vertical scale of graph
* object, the default value of that is 1.0 which presents 100%.
*
* The optional parameter "Hyperlink" specifies the hyperlink of the graph
* object.
*
* The optional parameter "HyperlinkType" defines two types of
* hyperlink "External" for website or "Location" for moving to one of the
* cells in this workbook. When the "HyperlinkType" is "Location",
* coordinates need to start with "#".
*
* The optional parameter "Positioning" defines 3 types of the position of a
* graph object in a spreadsheet: "oneCell" (Move but don't size with
* cells), "twoCell" (Move and size with cells), and "absolute" (Don't move
* or size with cells). If you don't set this parameter, the default
* positioning is to move and size with cells.
* @param sheet The worksheet name
* @param cell The cell reference
* @param pic The picture format options
*/
AddPictureFromBytes(sheet: string, cell: string, pic: Picture): { error: string | null }
/**
* AddFormControl provides the method to add form control button in a
* worksheet by given worksheet name and form control options. Supported
* form control type: button, check box, group box, label, option button,
* scroll bar and spinner. If set macro for the form control, the workbook
* extension should be XLSM or XLTM. Scroll value must be between 0 and
* 30000.
*
* Example 1, add button form control with macro, rich-text, custom button
* size, print property on Sheet1!A2, and let the button do not move or
* size with cells:
*
* ```typescript
* const { error } = f.AddFormControl('Sheet1', {
* Cell: 'A2',
* Type: excelize.FormControlButton,
* Macro: 'Button1_Click',
* Width: 140,
* Height: 60,
* Text: 'Button 1\r\n',
* Paragraph: [
* {
* Font: {
* Bold: true,
* Italic: true,
* Underline: 'single',
* Family: 'Times New Roman',
* Size: 14,
* Color: '777777',
* },
* Text: 'C1=A1+B1',
* },
* ],
* Format: {
* PrintObject: true,
* Positioning: 'absolute',
* },
* });
* ```
*
* Example 2, add option button form control with checked status and text
* on Sheet1!A1:
*
* ```typescript
* const { error } = f.AddFormControl('Sheet1', {
* Cell: 'A1',
* Type: excelize.FormControlOptionButton,
* Text: 'Option Button 1',
* Checked: true,
* });
* ```
*
* Example 3, add spin button form control on Sheet1!B1 to increase or
* decrease the value of Sheet1!A1:
*
* ```typescript
* const { error } = f.AddFormControl('Sheet1', {
* Cell: 'B1',
* Type: excelize.FormControlSpinButton,
* Width: 15,
* Height: 40,
* CurrentVal: 7,
* MinVal: 5,
* MaxVal: 10,
* IncChange: 1,
* CellLink: 'A1',
* });
* ```
*
* Example 4, add horizontally scroll bar form control on Sheet1!A2 to
* change the value of Sheet1!A1 by click the scroll arrows or drag the
* scroll box:
*
* ```typescript
* const { error } = f.AddFormControl('Sheet1', {
* Cell: 'A2',
* Type: excelize.FormControlScrollBar,
* Width: 140,
* Height: 20,
* CurrentVal: 50,
* MinVal: 10,
* MaxVal: 100,
* IncChange: 1,
* PageChange: 1,
* CellLink: 'A1',
* Horizontally: true,
* });
* ```
*
* @param sheet The worksheet name
* @param opts The form control options
*/
AddFormControl(sheet: string, opts: FormControl): { error: string | null }
/**
* AddPivotTable provides the method to add pivot table by given pivot
* table options. Note that the same fields can not in Columns, Rows and
* Filter fields at the same time.
*
* For example, create a pivot table on the range reference Sheet1!G2:M34
* with the range reference Sheet1!A1:E31 as the data source, summarize by
* sum for sales:
*
* ```typescript
* const { init } = require('excelize-wasm');
* const fs = require('fs');
*
* init('./node_modules/excelize-wasm/excelize.wasm.gz').then((excelize) => {
* const f = excelize.NewFile();
* if (f.error) {
* console.log(f.error);
* return;
* }
* // Create some data in a sheet
* const month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
* const year = [2017, 2018, 2019];
* const types = ['Meat', 'Dairy', 'Beverages', 'Produce'];
* const region = ['East', 'West', 'North', 'South'];
* f.SetSheetRow('Sheet1', 'A1', ['Month', 'Year', 'Type', 'Sales', 'Region']);
* const randInt = (max) => {
* return Math.floor(Math.random() * max);
* }
* for (let row = 2; row < 32; row++) {
* f.SetCellValue('Sheet1', 'A' + row.toString(), month[randInt(12)]);
* f.SetCellValue('Sheet1', 'B' + row.toString(), year[randInt(3)]);
* f.SetCellValue('Sheet1', 'C' + row.toString(), types[randInt(4)]);
* f.SetCellValue('Sheet1', 'D' + row.toString(), randInt(5000));
* f.SetCellValue('Sheet1', 'E' + row.toString(), region[randInt(4)]);
* }
* const ret = f.AddPivotTable({
* DataRange: 'Sheet1!A1:E31',
* PivotTableRange: 'Sheet1!G2:M34',
* Rows: [{ Data: 'Month', DefaultSubtotal: true }, { Data: 'Year' }],
* Filter: [{ Data: 'Region' }],
* Columns: [{ Data: 'Type', DefaultSubtotal: true }],
* Data: [{ Data: 'Sales', Name: 'Summarize', Subtotal: 'Sum' }],
* RowGrandTotals: true,
* ColGrandTotals: true,
* ShowDrill: true,
* ShowRowHeaders: true,
* ShowColHeaders: true,
* ShowLastColumn: true,
* });
* if (ret.error) {
* console.log(ret.error);
* return;
* }
* const { buffer, error } = f.WriteToBuffer();
* if (error) {
* console.log(error);
* return;
* }
* fs.writeFile('Book1.xlsx', buffer, 'binary', (error) => {
* if (error) {
* console.log(error);
* }
* });
* });
* ```
*
* @param opt The pivot table option
*/
AddPivotTable(opt: PivotTableOptions): { error: string | null }
/**
* AddShape provides the method to add shape in a sheet by given worksheet
* index, shape format set (such as offset, scale, aspect ratio setting
* and print settings) and properties set.
* @param sheet The worksheet name
* @param opts The shape options
*/
AddShape(sheet: string, opts: Shape): { error: string | null }
/**
* AddSlicer function inserts a slicer by giving the worksheet name and
* slicer settings.
* @param sheet The worksheet name
* @param opts The slicer options
*/
AddSlicer(sheet: string, opts: SlicerOptions): { error: string | null }
/**
* AddSparkline provides a function to add sparklines to the worksheet by
* given formatting options. Sparklines are small charts that fit in a single
* cell and are used to show trends in data. Sparklines are a feature of Excel
* 2010 and later only. You can write them to an XLSX file that can be read by
* Excel 2007, but they won't be displayed. For example, add a grouped
* sparkline. Changes are applied to all three:
*
* ```typescript
* const { error } = f.AddSparkline('Sheet1', {
* Location: ['A1', 'A2', 'A3'],
* Range: ['Sheet2!A1:J1', 'Sheet2!A2:J2', 'Sheet2!A3:J3'],
* Markers: true,
* });
* ```
*
* The following shows the formatting options of sparkline supported by excelize-wasm:
*
* Parameter | Description
* -------------+--------------------------------------------
* Location | Required, must have the same number with 'Range' parameter
* Range | Required, must have the same number with 'Location' parameter
* Type | Enumeration value: line, column, win_loss
* Style | Value range: 0 - 35
* Hight | Toggle sparkline high points
* Low | Toggle sparkline low points
* First | Toggle sparkline first points
* Last | Toggle sparkline last points
* Negative | Toggle sparkline negative points
* Markers | Toggle sparkline markers
* Axis | Used to specify if show horizontal axis
* Reverse | Used to specify if enable plot data right-to-left
* SeriesColor | An RGB Color is specified as RRGGBB
*
* @param sheet The worksheet name
* @param opts The sparkline options
*/
AddSparkline(sheet: string, opts: SparklineOptions): { error: string | null }
/**
* AddTable provides the method to add table in a worksheet by given
* worksheet name, range reference and format set.
* @param sheet The worksheet name
* @param rangeRef The top-left and right-bottom cell range reference
* @param opts The table options
*/
AddTable(sheet: string, opts: TableOptions): { error: string | null }
/**
* AutoFilter provides the method to add auto filter in a worksheet by
* given worksheet name, range reference and settings. An auto filter in
* Excel is a way of filtering a 2D range of data based on some simple
* criteria.
* @param sheet The worksheet name
* @param rangeRef The top-left and right-bottom cell range reference
* @param opts The auto filter options
*/
AutoFilter(sheet: string, rangeRef: string, opts: AutoFilterOptions[]): { error: string | null }
/**
* CalcCellValue provides a function to get calculated cell value. This
* feature is currently in working processing. Iterative calculation,
* implicit intersection, explicit intersection, array formula, table
* formula and some other formulas are not supported currently.
* @param sheet The worksheet name
* @param cell The cell reference
* @param opts The options for get calculated cell value
*/
CalcCellValue(sheet: string, cell: string, opts?: Options): { value: string, error: string | null }
/**
* CopySheet provides a function to duplicate a worksheet by gave source
* and target worksheet index. Note that currently doesn't support
* duplicate workbooks that contain tables, charts or pictures.
* @param from Source sheet index
* @param to Target sheet index
*/
CopySheet(from: number, to: number): { error: string | null }
/**
* DeleteChart provides a function to delete chart in spreadsheet by given
* worksheet name and cell reference.
* @param sheet The worksheet name
* @param cell The cell reference
*/
DeleteChart(sheet: string, cell: string): { error: string | null }
/**
* DeleteComment provides the method to delete comment in a sheet by given
* worksheet name.
* @param sheet The worksheet name
* @param cell The cell reference
*/
DeleteComment(sheet: string, cell: string): { error: string | null }
/**
* DeleteDataValidation delete data validation by given worksheet name and
* reference sequence. All data validations in the worksheet will be
* deleted if not specify reference sequence parameter.
* @param sheet The worksheet name
* @param sqref The cell reference sequence
*/
DeleteDataValidation(sheet: string, sqref?: string): { error: string | null }
/**
* DeleteDefinedName provides a function to delete the defined names of the
* workbook or worksheet. If not specified scope, the default scope is
* workbook.
* @param definedName The name for a cell or cell range on a worksheet
*/
DeleteDefinedName(definedName: DefinedName): { error: string | null }
/**
* DeleteFormControl provides the method to delete form control in a
* worksheet by given worksheet name and cell reference.
* @param sheet The worksheet name
* @param cell The cell reference
*/
DeleteFormControl(sheet: string, cell: string): { error: string | null }
/**
* DeletePicture provides a function to delete charts in spreadsheet by
* given worksheet name and cell reference. Note that the image file won't
* be deleted from the document currently.
* @param sheet The worksheet name
* @param cell The cell reference
*/
DeletePicture(sheet: string, cell: string): { error: string | null }
/**
* DeleteSheet provides a function to delete worksheet in a workbook by
* given worksheet name. Use this method with caution, which will affect
* changes in references such as formulas, charts, and so on. If there is
* any referenced value of the deleted worksheet, it will cause a file
* error when you open it. This function will be invalid when only one
* worksheet is left.
* @param sheet The worksheet name
*/
DeleteSheet(sheet: string): { error: string | null }
/**
* DeleteSlicer provides the method to delete a slicer by a given slicer
* name.
* @param name The slicer name
*/
DeleteSlicer(name: string): { error: string | null }
/**
* DeleteTable provides the method to delete table by given table name.
* @param name The table name
*/
DeleteTable(name: string): { error: string | null }
/**
* DuplicateRow inserts a copy of specified row (by its Excel row number)
* below. Use this method with caution, which will affect changes in
* references such as formulas, charts, and so on. If there is any
* referenced value of the worksheet, it will cause a file error when you
* open it. The excelize only partially updates these references
* currently.
* @param sheet The worksheet name
* @param row The row number
*/
DuplicateRow(sheet: string, row: number): { error: string | null }
/**
* DuplicateRowTo inserts a copy of specified row by it Excel number to
* specified row position moving down exists rows after target position.
* Use this method with caution, which will affect changes in references
* such as formulas, charts, and so on. If there is any referenced value
* of the worksheet, it will cause a file error when you open it. The
* excelize only partially updates these references currently.
* @param sheet The worksheet name
* @param row The source row number
* @param row2 The target row number
*/
DuplicateRowTo(sheet: string, row: number, row2: number): { error: string | null }
/**
* GetActiveSheetIndex provides a function to get active sheet index of the
* spreadsheet. If not found the active sheet will be return integer 0.
*/
GetActiveSheetIndex(): { index: number, error: string | null }
/**
* GetAppProps provides a function to get document application properties.
* @return This is the document application properties.
*/
GetAppProps(): { props?: AppProperties, error: string | null };
/**
* GetBaseColor returns the preferred hex color code by giving hex color
* code, indexed color, and theme color.
*/
GetBaseColor(hexColor: string, indexedColor: number, themeColor?: number): { color?: string, error: string | null };
/**
* GetCellFormula provides a function to get formula from cell by given
* worksheet name and cell reference in spreadsheet.
* @param sheet The worksheet name
* @param cell The cell reference
*/
GetCellFormula(sheet: string, cell: string): { formula: string, error: string | null }
/**
* GetCellHyperLink gets a cell hyperlink based on the given worksheet name
* and cell reference. If the cell has a hyperlink, it will return 'true'
* and the link address, otherwise it will return 'false' and an empty
* link address.
* @param sheet The worksheet name
* @param cell The cell reference
*/
GetCellHyperLink(sheet: string, cell: string): { ok: boolean, location: string, error: string | null }
/**
* GetCellRichText provides a function to get rich text of cell by given
* worksheet.
* @param sheet The worksheet name
* @param cell The cell reference
*/
GetCellRichText(sheet: string, cell: string): { runs: RichTextRun[], error: string | null }
/**
* GetCellStyle provides a function to get cell style index by given
* worksheet name and cell reference.
* @param sheet The worksheet name
* @param cell The cell reference
*/
GetCellStyle(sheet: string, cell: string): { style: number, error: string | null }
/**
* GetCellType provides a function to get the cell's data type by given
* worksheet name and cell reference in spreadsheet file.
* @param sheet The worksheet name
* @param cell The cell reference
*/
GetCellStyle(sheet: string, cell: string): { cellType: CellType, error: string | null }
/**
* GetCellValue provides a function to get formatted value from cell by
* given worksheet name and cell reference in spreadsheet. The return value
* is converted to the 'string' data type. If the cell format can be
* applied to the value of a cell, the applied value will be returned,
* otherwise the original value will be returned. All cells' values will be
* the same in a merged range.
* @param sheet The worksheet name
* @param cell The cell reference
* @param opts The options for get cell value
*/
GetCellValue(sheet: string, cell: string, opts?: Options): { value: string, error: string | null }
/**
* GetColOutlineLevel provides a function to get outline level of a single
* column by given worksheet name and column name.
* @param sheet The worksheet name
* @param col The column name
*/
GetColOutlineLevel(sheet: string, col: string): { level: number, error: string | null }
/**
* GetColStyle provides a function to get column style ID by given
* worksheet name and column name.
* @param sheet The worksheet name
* @param col The column name
*/
GetColStyle(sheet: string, col: string): { style: number, error: string | null }
/**
* GetColVisible provides a function to get visible of a single column by
* given worksheet name and column name.
* @param sheet The worksheet name
* @param col The column name
*/
GetColVisible(sheet: string, col: string): { visible: boolean, error: string | null }
/**
* GetColWidth provides a function to get column width by given worksheet
* name and column name.
* @param sheet The worksheet name
* @param col The column name
*/
GetColWidth(sheet: string, col: string): { width: number, error: string | null }
/**
* GetCols gets the value of all cells by columns on the worksheet based on
* the given worksheet name, returned as a two-dimensional array, where
* the value of the cell is converted to the `string` type. If the cell
* format can be applied to the value of the cell, the applied value will
* be used, otherwise the original value will be used.
* @param sheet The worksheet name
* @param opts The options for get column cells
*/
GetCols(sheet: string, opts?: Options): { result: string[][], error: string | null }
/**
* GetComments retrieves all comments in a worksheet by given worksheet
* name.
* @param sheet The worksheet name
*/
GetComments(sheet: string): { comments: Comment[], error: string | null }
/**
* GetConditionalStyle returns conditional format style definition by
* specified style index.
* @param styleID The style ID
*/
GetConditionalStyle(styleID: number): { style: Style, error: string | null }
/**
* GetDefaultFont provides the default font name currently set in the
* workbook. The spreadsheet generated by excelize default font is Calibri.
*/
GetDefaultFont(): { fontName: string, error: string | null }
/**
* GetDefinedName provides a function to get the defined names of the
* workbook or worksheet.
*/
GetDefinedName(): { definedNames: DefinedName[], error: string | null }
/**
* GetDocProps provides a function to get document core properties.
*/
GetDocProps(): { props: DocProperties, error: string | null }
/**
* GetFormControls retrieves all form controls in a worksheet by a given
* worksheet name. Note that, this function does not support getting the
* width and height of the form controls currently.
* @param sheet The worksheet name
*/
GetFormControls(sheet: string): { formControls: FormControl[], error: string | null }
/**
* GetHeaderFooter provides a function to get worksheet header and footer by
* given worksheet name.
* @param sheet The worksheet name
*/
GetHeaderFooter(sheet: string): { opts: HeaderFooterOptions, error: string | null }
/**
* GetMergeCells provides a function to get all merged cells from a specific
* worksheet.
* @param sheet The worksheet name
*/
GetMergeCells(sheet: string): { mergeCells: MergeCell[], error: string | null }
/**
* GetPageLayout provides a function to gets worksheet page layout.
* @param sheet The worksheet name
*/
GetPageLayout(sheet: string): { opts: PageLayoutOptions, error: string | null }
/**
* GetPanes provides a function to get freeze panes, split panes, and
* worksheet views by given worksheet name.
* @param sheet The worksheet name
*/
GetPanes(sheet: string): { panes: Panes, error: string | null }
/**
* GetPictures provides a function to get picture meta info and raw content
* embed in spreadsheet by given worksheet and cell name. This function
* returns the image contents as []byte data types. This function is
* concurrency safe. For example:
*
* ```typescript
* const { init } = require('excelize-wasm');
* const fs = require('fs');
*
* init('./node_modules/excelize-wasm/excelize.wasm.gz').then((excelize) => {
* const f = excelize.OpenReader(fs.readFileSync('Book1.xlsx'));
* if (f.error) {
* console.log(f.error);
* return
* }
* const { pictures, error } = f.GetPictures('Sheet1', 'A2')
* if (error) {
* console.log(error);
* return;
* }
* pictures.forEach((pic, idx) => {
* const name = 'image'+idx.toString()+pic.Extension;
* fs.writeFile(name, pic.File, 'binary', (error) => {
* if (error) {
* console.log(error);
* }
* });
* });
* });
* ```
*
* @param sheet The worksheet name
* @param cell The cell reference
*/
GetPictures(sheet: string, cell: string): { pictures: Picture[], error: string | null }
/**
* GetPictureCells returns all picture cell references in a worksheet by a
* specific worksheet name.
* @param sheet The worksheet name
*/
GetPictureCells(sheet: string): { cells: string[], error: string | null }
/**
* GetPivotTables returns all pivot table definitions in a worksheet by
* given worksheet name.
*/
GetPivotTables(sheet: string): { opts: PivotTableOptions[], error: string | null }
/**
* GetRowHeight provides a function to get row height by given worksheet
* name and row number. For example, get the height of the first row in
* Sheet1:
*
* ```typescript
* const { height, error } = f.GetRowHeight('Sheet1', 1);
* ```
*
* @param sheet The worksheet name
* @param row The row number
*/
GetRowHeight(sheet: string, row: number): { height: number, error: string | null }
/**
* GetRowOutlineLevel provides a function to get outline level number of a
* single row by given worksheet name and Excel row number.
* @param sheet The worksheet name
* @param row The row number
*/
GetRowOutlineLevel(sheet: string, row: number): { level: number, error: string | null }
/**
* GetRowVisible provides a function to get visible of a single row by
* given worksheet name and Excel row number. For example, get visible state
* of row 2 in Sheet1:
*
* ```typescript
* const { visible, error } = f.GetRowVisible('Sheet1', 2);
* ```
*
* @param sheet The worksheet name
* @param row The row number
*/
GetRowVisible(sheet: string, row: number): { visible: boolean, error: string | null }
/**
* GetRows return all the rows in a sheet by given worksheet name, returned
* as a two-dimensional array, where the value of the cell is converted to
* the string type. If the cell format can be applied to the value of the
* cell, the applied value will be used, otherwise the original value will
* be used. GetRows fetched the rows with value or formula cells, the
* continually blank cells in the tail of each row will be skipped, so the
* length of each row may be inconsistent.
*
* For example, get and traverse the value of all cells by rows on a
* worksheet named 'Sheet1':
*
* ```typescript
* const { result, error } = f.GetRows('Sheet1');
* if (error) {
* console.log(error);
* return;
* }
* result.forEach((row) => {
* row.forEach((colCell) => {
* process.stdout.write(`${colCell}\t`);
* });
* console.log();
* });
* ```
*
* @param sheet The worksheet name
* @param opts The options for get rows
*/
GetRows(sheet: string, opts?: Options): { result: string[][], error: string | null }
/**
* GetSheetIndex provides a function to get a sheet index of the workbook
* by the given sheet name. If the given sheet name is invalid or sheet
* doesn't exist, it will return an integer type value -1.
* @param sheet The worksheet name
*/
GetSheetIndex(sheet: string): { index: number, error: string | null }
/**
* GetSheetList provides a function to get worksheets, chart sheets, and
* dialog sheets name list of the workbook.
*/
GetSheetList(): { list: string[] }
/**
* GetSheetMap provides a function to get worksheets, chart sheets, dialog
* sheets ID and name map of the workbook.
*/
GetSheetMap(): { sheets: Map<string,string>, error: string | null }
/**
* GetSheetName provides a function to get the sheet name of the workbook
* by the given sheet index. If the given sheet index is invalid, it will
* return an empty string.
* @param index The sheet index
*/
GetSheetName(index: number): { name: string, error: string | null }
/**
* GetSheetProps provides a function to get worksheet properties.
* @param sheet The worksheet name
*/
GetSheetProps(sheet: string): { props: SheetPropsOptions, error: string | null }
/**
* GetSheetView gets the value of sheet view options. The viewIndex may be
* negative and if so is counted backward (-1 is the last view).
* @param sheet The worksheet name
* @param viewIndex The sheet view index
*/
GetSheetView(sheet: string, viewIndex: number): { opts: ViewOptions, error: string | null }
/**
* GetSheetVisible provides a function to get worksheet visible by given
* worksheet name.
* @param sheet The worksheet name
*/
GetSheetVisible(sheet: string): { visible: boolean, error: string | null }
/**
* GetSlicers provides the method to get all slicers in a worksheet by a
* given worksheet name. Note that, this function does not support getting
* the height, width, and graphic options of the slicer shape currently.
* @param sheet The worksheet name
*/
GetSlicers(sheet: number): { slicers: SlicerOptions[], error: string | null }
/**
* GetStyle provides a function to get style definition by given style index.
* @param styleID The style ID
*/
GetStyle(styleID: number): { style: Style, error: string | null }
/**
* GetTables provides the method to get all tables in a worksheet by given
* worksheet name.
* @param sheet The worksheet name
*/
GetTables(sheet: string): { tables: TableOptions[], error: string | null }
/**
* GetWorkbookProps provides a function to gets workbook properties.
*/
GetWorkbookProps(): { props: WorkbookPropsOptions, error: string | null }
/**
* GroupSheets provides a function to group worksheets by given worksheets
* name. Group worksheets must contain an active worksheet.
* @param sheets The worksheet names
*/
GroupSheets(sheets: string[]): { error: string | null }
/**
* InsertCols provides a function to insert new columns before the given
* column name and number of columns.
*
* Use this method with caution, which will affect changes in references
* such as formulas, charts, and so on. If there is any referenced value
* of the worksheet, it will cause a file error when you open it. The
* excelize only partially updates these references currently.
* @param sheet The worksheet name
* @param col The base column name
* @param n The insert columns count
*/
InsertCols(sheet: string, col: string, n: number): { error: string | null }
/**
* InsertPageBreak create a page break to determine where the printed page
* ends and where begins the next one by given worksheet name and cell, so
* the content before the page break will be printed on one page and after
* the page break on another.
* @param sheet The worksheet name
* @param cell The cell reference
*/
InsertPageBreak(sheet: string, cell: string): { error: string | null }
/**
* InsertRows provides a function to insert new rows after the given Excel
* row number starting from 1 and number of rows.
*
* Use this method with caution, which will affect changes in references
* such as formulas, charts, and so on. If there is any referenced value
* of the worksheet, it will cause a file error when you open it. The
* excelize only partially updates these references currently.
* @param sheet The worksheet name
* @param row The base row number
* @param n Insert rows count
*/
InsertRows(sheet: string, row: number, n: number): { error: string | null }
/**
* MergeCell provides a function to merge cells by given range reference
* and sheet name. Merging cells only keeps the upper-left cell value, and
* discards the other values. For example create a merged cell of D3:E9 on
* Sheet1:
*
* ```typescript
* const { error } = f.MergeCell('Sheet1', 'D3', 'E9');
* ```
*
* If you create a merged cell that overlaps with another existing merged
* cell, those merged cells that already exist will be removed. The cell
* references tuple after merging in the following range will be: A1
* (x3,y1) D1(x2,y1) A8(x3,y4) D8(x2,y4)
*
* B1(x1,y1) D1(x2,y1)
* +------------------------+
* | |
* A4(x3,y3) | C4(x4,y3) |
* +------------------------+ |
* | | | |
* | |B5(x1,y2) | D5(x2,y2)|
* | +------------------------+
* | |
* |A8(x3,y4) C8(x4,y4)|
* +------------------------+
* @param sheet The worksheet name
* @param topLeftCell The top-left cell reference
* @param bottomRightCell The right-bottom cell reference
*/
MergeCell(sheet: string, topLeftCell: string, bottomRightCell: string): { error: string | null }
/**
* MoveSheet moves a sheet to a specified position in the workbook. The
* function moves the source sheet before the target sheet. After moving,
* other sheets will be shifted to the left or right. If the sheet is
* already at the target position, the function will not perform any action.
* Not that this function will be ungroup all sheets after moving. For
* example, move Sheet2 before Sheet1:
*
* ```typescript
* const { error } = f.MoveSheet('Sheet2', 'Sheet1');
* ```
*
* @param source The source sheet name
* @param target The target sheet name
*/
MoveSheet(source: string, target: string): { error: string | null }
/**
* NewConditionalStyle provides a function to create style for conditional
* format by given style format. The parameters are the same with the
* NewStyle function. Note that the color field uses RGB color code and
* only support to set font, fills, alignment and borders currently.
* @param style
*/
NewConditionalStyle(style: Style): { style: number, error: string | null }
/**
* NewSheet provides the function to create a new sheet by given a
* worksheet name and returns the index of the sheets in the workbook
* after it appended. Note that when creating a new workbook, the default
* worksheet named `Sheet1` will be created.
* @param sheet The worksheet name
*/
NewSheet(sheet: string): { index: number, error: string | null }
/**
* ProtectSheet provides a function to prevent other users from
* accidentally or deliberately changing, moving, or deleting data in a
* worksheet. The optional field AlgorithmName specified hash algorithm,
* support XOR, MD4, MD5, SHA-1, SHA2-56, SHA-384, and SHA-512 currently,
* if no hash algorithm specified, will be using the XOR algorithm as
* default. For example, protect Sheet1 with protection settings:
*
* ```typescript
* const { error } = f.ProtectSheet('Sheet1', {
* AlgorithmName: 'SHA-512',
* Password: 'password',
* SelectLockedCells: true,
* SelectUnlockedCells: true,
* EditScenarios: true,
* });
* ```
*
* @param sheet The worksheet name
* @param opts The worksheet protection options
*/
ProtectSheet(sheet: string, opts: SheetProtectionOptions): { error: string | null }
/**
* ProtectWorkbook provides a function to prevent other users from viewing
* hidden worksheets, adding, moving, deleting, or hiding worksheets, and
* renaming worksheets in a workbook. The optional field AlgorithmName
* specified hash algorithm, support XOR, MD4, MD5, SHA-1, SHA2-56,
* SHA-384, and SHA-512 currently, if no hash algorithm specified, will be
* using the XOR algorithm as default. The generated workbook only works on
* Microsoft Office 2007 and later. For example, protect workbook with
* protection settings:
*
* ```typescript
* const { error } = f.ProtectWorkbook({
* Password: 'password',
* LockStructure: true,
* });
* ```
*
* @param opts The workbook protection options
*/
ProtectWorkbook(opts: WorkbookProtectionOptions): { error: string | null }
/**
* NewStyle provides a function to create the style for cells by given
* options. Note that the color field uses RGB color code.
* @param style The style options
*/
NewStyle(style: Style): { style: number, error: string | null }
/**
* RemoveCol provides a function to remove single column by given worksheet
* name and column index.
*
* Use this method with caution, which will affect changes in references
* such as formulas, charts, and so on. If there is any referenced value
* of the worksheet, it will cause a file error when you open it. The
* excelize only partially updates these references currently.
* @param sheet The worksheet name
* @param col The column name
*/
RemoveCol(sheet: string, col: string): { error: string | null }
/**
* RemovePageBreak remove a page break by given worksheet name and cell
* reference.
* @param sheet The worksheet name
* @param cell The cell reference
*/
RemovePageBreak(sheet: string, cell: string): { error: string | null }
/**
* RemoveRow provides a function to remove single row by given worksheet
* name and Excel row number.
*
* Use this method with caution, which will affect changes in references
* such as formulas, charts, and so on. If there is any referenced value
* of the worksheet, it will cause a file error when you open it. The
* excelize only partially updates these references currently.
* @param sheet The worksheet name
* @param row The row number
*/
RemoveRow(sheet: string, row: number): { error: string | null }
/**
* SearchSheet provides a function to get cell reference by given worksheet
* name, cell value, and regular expression. The function doesn't support
* searching on the calculated result, formatted numbers and conditional
* lookup currently. If it is a merged cell, it will return the cell
* reference of the upper left cell of the merged range reference.
* @param sheet The worksheet name
* @param value The cell value to search
* @param reg Specifies if search with regular expression
*/
SearchSheet(sheet: string, value: string, reg?: boolean): { result: string[], error: string | null }
/**
* SetActiveSheet provides a function to set the default active sheet of
* the workbook by a given index. Note that the active index is different
* from the ID returned by function GetSheetMap(). It should be greater
* than or equal to 0 and less than the total worksheet numbers.
* @param index The sheet index
*/
SetActiveSheet(index: number): { error: string | null }
/**
* SetAppProps provides a function to set document application properties.
* The properties that can be set are:
*
* Property | Description
* -------------------+---------------------------------------------------
* Application | The name of the application that created this
* | document.
* |
* ScaleCrop | Indicates the display mode of the document
* | thumbnail. Set this element to 'true' to enable
* | scaling of the document thumbnail to the display.
* | Set this element to 'false' to enable cropping of
* | the document thumbnail to show only sections that
* | will fit the display.
* |
* DocSecurity | Security level of a document as a numeric value.
* | Document security is
* |
* | defined as:
* | 1 - Document is password protected.
* | 2 - Document is recommended to be opened as read-only.
* | 3 - Document is enforced to be opened as read-only.
* | 4 - Document is locked for annotation.
* |
* Company | The name of a company associated with the document.
* |
* LinksUpToDate | Indicates whether hyperlinks in a document are
* | up-to-date. Set this
* | element to 'true' to indicate that hyperlinks are
* | updated. Set this element to 'false' to indicate
* | that hyperlinks are outdated.
* |
* HyperlinksChanged | Specifies that one or more hyperlinks in this part
* | were updated exclusively in this part by a
* | producer. The next producer to open this document
* | shall update the hyperlink relationships with the
* | new hyperlinks specified in this part.
* |
* AppVersion | Specifies the version of the application which
* | produced this document. The content of this
* | element shall be of the form XX.YYYY where X and Y
* | represent numerical values, or the document shall
* | be considered non-conformant.
*
* For example:
*
* ```typescript
* const { error } = f.SetAppProps({
* Application: 'Microsoft Excel',
* ScaleCrop: true,
* DocSecurity: 3,
* Company: 'Company Name',
* LinksUpToDate: true,
* HyperlinksChanged: true,
* AppVersion: '16.0000',
* });
* ```
*
* @param props The application properties
*/
SetAppProps(props: AppProperties): { error: string | null }
/**
* SetCellBool provides a function to set bool type value of a cell by
* given worksheet name, cell reference and cell value.
* @param sheet The worksheet name
* @param cell The cell reference
* @param value The cell value to be write
*/
SetCellBool(sheet: string, cell: string, value: boolean): { error: string | null }
/**
* SetCellDefault provides a function to set string type value of a cell as
* default format without escaping the cell.
* @param sheet The worksheet name
* @param cell The cell reference
* @param value The cell value to be write
*/
SetCellDefault(sheet: string, cell: string, value: string): { error: string | null }
/**
* SetCellFloat sets a floating point value into a cell. The precision
* parameter specifies how many places after the decimal will be shown
* while -1 is a special value that will use as many decimal places as
* necessary to represent the number. bitSize is 32 or 64 depending on if
* a float32 or float64 was originally used for the value.
* @param sheet The worksheet name
* @param cell The cell reference
* @param value The cell value to be write
* @param precision Specifies how many places after the decimal will be
* shown
* @param bitSize BitSize is 32 or 64 depending on if a float32 or float64
* was originally used for the value
*/
SetCellFloat(sheet: string, cell: string, value: number, precision: number, bitSize: number): { error: string | null }
/**
* SetCellFormula provides a function to set formula on the cell is taken
* according to the given worksheet name and cell formula settings. The
* result of the formula cell can be calculated when the worksheet is
* opened by the Office Excel application or can be using the
* "CalcCellValue" function also can get the calculated cell value. If the
* Excel application doesn't calculate the formula automatically when the
* workbook has been opened, please call "UpdateLinkedValue" after setting
* the cell formula functions.
*
* Example 1, set normal formula "=SUM(A1,B1)" for the cell "A3" on "Sheet1":
*
* ```typescript
* const { error } = f.SetCellFormula('Sheet1', 'A3', '=SUM(A1,B1)');
* ```
*
* Example 2, set one-dimensional vertical constant array (column array)
* formula "1,2,3" for the cell "A3" on "Sheet1":
*
* ```typescript
* const { error } = f.SetCellFormula('Sheet1', 'A3', '={1;2;3}');
* ```
*
* Example 3, set one-dimensional horizontal constant array (row array)
* formula '"a","b","c"' for the cell "A3" on "Sheet1":
*
* ```typescript
* const { error } = f.SetCellFormula('Sheet1', 'A3', '={"a","b","c"}');
* ```
*
* Example 4, set two-dimensional constant array formula '{1,2,"a","b"}' for
* the cell "A3" on "Sheet1":
*
* ```typescript
* const { error } = f.SetCellFormula('Sheet1', 'A3', '={1,2;"a","b"}',
* {Ref: 'A3:A3', Type: 'array'});
* ```
*
* Example 5, set range array formula "A1:A2" for the cell "A3" on "Sheet1":
*
* ```typescript
* const { error } = f.SetCellFormula('Sheet1', 'A3', '=A1:A2',
* {Ref: 'A3:A3', Type: 'array'});
* ```
*
* Example 6, set shared formula "=A1+B1" for the cell "C1:C5"
* on "Sheet1", "C1" is the master cell:
*
* ```typescript
* const { error } = f.SetCellFormula('Sheet1', 'C1', '=A1+B1',
* {Ref: 'C1:C5', Type: 'shared'});
* ```
*
* Example 7, set table formula "=SUM(Table1[[A]:[B]])" for the cell "C2"
* on "Sheet1":
*
* ```typescript
* const { init } = require('excelize-wasm');
* const fs = require('fs');
*
* init('./node_modules/excelize-wasm/excelize.wasm.gz').then((excelize) => {
* const f = excelize.NewFile();
* [
* ['A', 'B', 'C'],
* [1, 2],
* ].forEach((row, idx) => {
* var { error } = f.SetSheetRow('Sheet1', `A${idx + 1}`, row);
* if (error) {
* console.log(error);
* return;
* }
* });
* var { error } = f.AddTable('Sheet1', 'A1:C2', {
* Name: 'Table1',
* StyleName: 'TableStyleMedium2',
* });
* if (error) {
* console.log(error);
* return;
* }
* var { error } = f.SetCellFormula('Sheet1', 'C2', '=SUM(Table1[[A]:[B]])', {
* Type: 'dataTable',
* });
* if (error) {
* console.log(error);
* return;
* }
* // Save spreadsheet by the given path.
* var { buffer, error } = f.WriteToBuffer();
* if (error) {
* console.log(error);
* return;
* }
* fs.writeFile('Book1.xlsx', buffer, 'binary', (error) => {
* if (error) {
* console.log(error);
* }
* });
* });
* ```
*
* @param sheet The worksheet name
* @param cell The cell reference
* @param formula The cell formula
* @param opts The formula options
*/
SetCellFormula(sheet: string, cell: string, formula: string, opts?: FormulaOptions): { error: string | null }
/**
* SetCellHyperLink provides a function to set cell hyperlink by given
* worksheet name and link URL address. LinkType defines three types of
* hyperlink "External" for website or "Location" for moving to one of cell
* in this workbook or "None" for remove hyperlink. Maximum limit hyperlinks
* in a worksheet is 65530. This function is only used to set the hyperlink
* of the cell and doesn't affect the value of the cell. If you need to set
* the value of the cell, please use the other functions such as
* `SetCellStyle` or `SetSheetRow`.
* @param sheet The worksheet name
* @param cell The cell reference
* @param link The hyperlink
* @param linkType The hyperlink type
* @param opts The hyperlink options
*/
SetCellHyperLink(sheet: string, cell: string, link: string, linkType: string, opts?: HyperlinkOpts): { error: string | null }
/**
* SetCellInt provides a function to set int type value of a cell by given
* worksheet name, cell reference and cell value.
* @param sheet The worksheet name
* @param cell The cell reference
* @param value The cell value to be write
*/
SetCellInt(sheet: string, cell: string, value: number): { error: string | null }
/**
* SetCellUint provides a function to set uint type value of a cell by given
* worksheet name, cell reference and cell value.
* @param sheet The worksheet name
* @param cell The cell reference
* @param value The cell value to be write
*/
SetCellUint(sheet: string, cell: string, value: number): { error: string | null }
/**
* SetCellRichText provides a function to set cell with rich text by given
* worksheet. For example, set rich text on the A1 cell of the worksheet
* named Sheet1:
*
* ```typescript
* const { init } = require('excelize-wasm');
* const fs = require('fs');
*
* init('./node_modules/excelize-wasm/excelize.wasm.gz').then((excelize) => {
* const f = excelize.NewFile();
* var { error } = f.SetRowHeight('Sheet1', 1, 35);
* if (error) {
* console.log(error);
* return;
* }
* var { error } = f.SetColWidth('Sheet1', 'A', 'A', 44);
* if (error) {
* console.log(error);
* return;
* }
* var { error } = f.SetCellRichText('Sheet1', 'A1', [
* {
* Text: 'bold',
* Font: {
* Bold: true,
* Color: '2354e8',
* Family: 'Times New Roman',
* },
* },
* {
* Text: ' and ',
* Font: {
* Family: 'Times New Roman',
* },
* },
* {
* Text: 'italic ',
* Font: {
* Bold: true,
* Color: 'e83723',
* Italic: true,
* Family: 'Times New Roman',
* },
* },
* {
* Text: 'text with color and font-family,',
* Font: {
* Bold: true,
* Color: '2354e8',
* Family: 'Times New Roman',
* },
* },
* {
* Text: '\r\nlarge text with ',
* Font: {
* Size: 14,
* Color: 'ad23e8',
* },
* },
* {
* Text: 'strike',
* Font: {
* Color: 'e89923',
* Strike: true,
* },
* },
* {
* Text: ' superscript',
* Font: {
* Color: 'dbc21f',
* VertAlign: 'superscript',
* },
* },
* {
* Text: ' and ',
* Font: {
* Size: 14,
* Color: 'ad23e8',
* VertAlign: 'baseline',
* },
* },
* {
* Text: 'underline',
* Font: {
* Color: '23e833',
* Underline: 'single',
* },
* },
* {
* Text: ' subscript.',
* Font: {
* Color: '017505',
* VertAlign: 'subscript',
* },
* },
* ]);
* if (error) {
* console.log(error);
* return;
* }
* var { style, error } = f.NewStyle({
* Alignment: { WrapText: true },
* });
* if (error) {
* console.log(error);
* return;
* }
* var { error } = f.SetCellStyle('Sheet1', 'A1', 'A1', style);
* if (error) {
* console.log(error);
* return;
* }
* // Save spreadsheet by the given path.
* var { buffer, error } = f.WriteToBuffer();
* if (error) {
* console.log(error);
* return;
* }
* fs.writeFile('Book1.xlsx', buffer, 'binary', (error) => {
* if (error) {
* console.log(error);
* }
* });
* });
* ```
*
* @param sheet The worksheet name
* @param cell The cell reference
* @param runs The rich text runs
*/
SetCellRichText(sheet: string, cell: string, runs: RichTextRun[]): { error: string | null }
/**
* SetCellStr provides a function to set string type value of a cell. Total
* number of characters that a cell can contain 32767 characters.
* @param sheet The worksheet name
* @param cell The cell reference
* @param value The cell value to be write
*/
SetCellStr(sheet: string, cell: string, value: string): { error: string | null }
/**
* SetCellStyle provides a function to add style attribute for cells by
* given worksheet name, range reference and style ID. Note that
* diagonalDown and diagonalUp type border should be use same color in the
* same range. SetCellStyle will overwrite the existing styles for the
* cell, it won't append or merge style with existing styles.
* @param sheet The worksheet name
* @param topLeftCell The top-left cell reference
* @param bottomRightCell The right-bottom cell reference
* @param styleID The style ID
*/
SetCellStyle(sheet: string, topLeftCell: string, bottomRightCell: string, styleID: number): { error: string | null }
/**
* SetCellValue provides a function to set the value of a cell. The
* specified coordinates should not be in the first row of the table, a
* complex number can be set with string text.
*
* Note that default date format is m/d/yy h:mm of time.Time type value. You
* can set numbers format by the SetCellStyle function. If you need to set
* the specialized date in Excel like January 0, 1900 or February 29, 1900,
* these times can not representation in Go language time.Time data type.
* Please set the cell value as number 0 or 60, then create and bind the
* date-time number format style for the cell.
* @param sheet The worksheet name
* @param cell The cell reference
* @param value The cell value to be write
*/
SetCellValue(sheet: string, cell: string, value: boolean | number | string ): { error: string | null }
/**
* SetColOutlineLevel provides a function to set outline level of a single
* column by given worksheet name and column name. The value of parameter
* `level` is 1-7.
* @param sheet The worksheet name
* @param col The column name
* @param level The outline level of the column
*/
SetColOutlineLevel(sheet: string, col: string, level: number): { error: string | null }
/**
* SetColStyle provides a function to set style of columns by given
* worksheet name, columns range and style ID. Note that this will
* overwrite the existing styles for the columns, it won't append or merge
* style with existing styles.
* @param sheet The worksheet name
* @param columns The column range
* @param styleID The style ID
*/
SetColStyle(sheet: string, columns: string, styleID: number): { error: string | null }
/**
* SetColVisible provides a function to set visible columns by given
* worksheet name, columns range and visibility.
* @param sheet The worksheet name
* @param columns The column name
* @param visible The column's visibility
*/
SetColVisible(sheet: string, columns: string, visible: boolean): { error: string | null }
/**
* SetColWidth provides a function to set the width of a single column or
* multiple columns.
* @param sheet The worksheet name
* @param startCol The start column name
* @param endCol The end column name
* @param width The width of the column
*/
SetColWidth(sheet: string, startCol: string, endCol: string, width: number): { error: string | null }
/**
* SetConditionalFormat provides a function to create conditional
* formatting rule for cell value. Conditional formatting is a feature of
* Excel which allows you to apply a format to a cell or a range of cells
* based on certain criteria.
* @param sheet The worksheet name
* @param reference The conditional format range reference
* @param opts The conditional options
*/
SetConditionalFormat(sheet: string, reference: string, opts: ConditionalFormatOptions[]): { error: string | null }
/**
* SetDefaultFont changes the default font in the workbook.
* @param fontName The font name
*/
SetDefaultFont(fontName: string): { error: string | null }
/**
* SetDefinedName provides a function to set the defined names of the
* workbook or worksheet. If not specified scope, the default scope is
* workbook.
* @param definedName The name for a cell or cell range on a worksheet
*/
SetDefinedName(definedName: DefinedName): { error: string | null }
/**
* SetDocProps provides a function to set document core properties. The
* properties that can be set are:
*
* Property | Description
* ----------------+-----------------------------------------------------------
* Title | The name given to the resource.
* |
* Subject | The topic of the content of the resource.
* |
* Creator | An entity primarily responsible for making the content of
* | the resource.
* |
* Keywords | A delimited set of keywords to support searching and
* | indexing. This is typically a list of terms that are not
* | available elsewhere in the properties.
* |
* Description | An explanation of the content of the resource.
* |
* LastModifiedBy | The user who performed the last modification. The
* | identification is environment-specific.
* |
* Language | The language of the intellectual content of the resource.
* |
* Identifier | An unambiguous reference to the resource within a given
* | context.
* |
* Revision | The topic of the content of the resource.
* |
* ContentStatus | The status of the content. For example: Values might
* | include "Draft", "Reviewed" and "Final"
* |
* Category | A categorization of the content of this package.
* |
* Version | The version number. This value is set by the user or by
* | the application.
* |
* Created | The created time of the content of the resource which
* | represent in ISO 8601 UTC format, for example
* | "2019-06-04T22:00:10Z".
* |
* Modified | The modified time of the content of the resource which
* | represent in ISO 8601 UTC format, for example
* | "2019-06-04T22:00:10Z".
* |
*
* For example:
*
* ```typescript
* const { error } = f.SetDocProps({
* Category: 'category',
* ContentStatus: 'Draft',
* Created: '2019-06-04T22:00:10Z',
* Creator: 'Go Excelize',
* Description: 'This file created by Go Excelize',
* Identifier: 'xlsx',
* Keywords: 'Spreadsheet',
* LastModifiedBy: 'Go Author',
* Modified: '2019-06-04T22:00:10Z',
* Revision: '0',
* Subject: 'Test Subject',
* Title: 'Test Title',
* Language: 'en-US',
* Version: '1.0.0',
* });
* ```
*
* @param docProperties The document core properties
*/
SetDocProps(docProperties: DocProperties): { error: string | null }
/**
* SetHeaderFooter provides a function to set headers and footers by given
* worksheet name and the control characters.
*
* Headers and footers are specified using the following settings fields:
*
* Fields | Description
* ------------------+-----------------------------------------------------------
* AlignWithMargins | Align header footer margins with page margins
* DifferentFirst | Different first-page header and footer indicator
* DifferentOddEven | Different odd and even page headers and footers indicator
* ScaleWithDoc | Scale header and footer with document scaling
* OddFooter | Odd Page Footer, or primary Page Footer if
* | 'DifferentOddEven' is 'false'
* OddHeader | Odd Header, or primary Page Header if 'DifferentOddEven'
* | is 'false'
* EvenFooter | Even Page Footer
* EvenHeader | Even Page Header
* FirstFooter | First Page Footer
* FirstHeader | First Page Header
*
* The following formatting codes can be used in 6 string type fields:
* OddHeader, OddFooter, EvenHeader, EvenFooter, FirstFooter, FirstHeader
*
* Formatting Code | Description
* ------------------------+----------------------------------------------------
* && | The character "&"
* |
* &font-size | Size of the text font, where font-size is a decimal
* | font size in points
* |
* &"font name,font type" | A text font-name string, font name, and a text
* | font-type string, font type
* |
* &"-,Regular" | Regular text format. Toggles bold and italic modes
* | to off
* |
* &A | Current worksheet's tab name
* |
* &B or &"-,Bold" | Bold text format, from off to on, or vice versa. The
* | default mode is off
* |
* &D | Current date
* |
* &C | Center section
* |
* &E | Double-underline text format
* |
* &F | Current workbook's file name
* |
* &G | Drawing object as background (Not support currently)
* |
* &H | Shadow text format
* |
* &I or &"-,Italic" | Italic text format
* |
* &K | Text font color
* |
* | An RGB Color is specified as RRGGBB
* |
* | A Theme Color is specified as TTSNNN where TT is the
* | theme color Id, S is either "+" or "-" of the
* | tint/shade value, and NNN is the tint/shade value
* |
* &L | Left section
* |
* &N | Total number of pages
* |
* &O | Outline text format
* |
* &P[[+|-]n] | Without the optional suffix, the current page
* | number in decimal
* |
* &R | Right section
* |
* &S | Strike through text format
* |
* &T | Current time
* |
* &U | Single-underline text format. If double-underline
* | mode is on, the next occurrence in a section
* | specifier toggles double-underline mode to off;
* | otherwise, it toggles single-underline mode, from
* | off to on, or vice versa. The default mode is off
* |
* &X | Superscript text format
* |
* &Y | Subscript text format
* |
* &Z | Current workbook's file path
*
* For example:
*
* ```typescript
* const { error } = f.SetHeaderFooter('Sheet1', {
* DifferentFirst: true,
* DifferentOddEven: true,
* OddHeader: '&R&P',
* OddFooter: '&C&F',
* EvenHeader: '&L&P',
* EvenFooter: '&L&D&R&T',
* FirstHeader: `&CCenter &"-,Bold"Bold&"-,Regular"HeaderU+000A&D`,
* });
* ```
*
* This example shows:
*
* - The first page has its own header and footer
*
* - Odd and even-numbered pages have different headers and footers
*
* - Current page number in the right section of odd-page headers
*
* - Current workbook's file name in the center section of odd-page footers
*
* - Current page number in the left section of even-page headers
*
* - Current date in the left section and the current time in the right section
* of even-page footers
*
* - The text "Center Bold Header" on the first line of the center section of
* the first page, and the date on the second line of the center section of
* that same page
*
* - No footer on the first page
* @param sheet The worksheet name
* @param opts The header footer options
*/
SetHeaderFooter(sheet: string, opts: HeaderFooterOptions): { error: string | null }
/**
* SetPageLayout provides a function to sets worksheet page layout. The
* following shows the paper size sorted by excelize index number:
*
* Index | Paper Size
* -------+-----------------------------------------------
* 1 | Letter paper (8.5 in. by 11 in.)
* 2 | Letter small paper (8.5 in. by 11 in.)
* 3 | Tabloid paper (11 in. by 17 in.)
* 4 | Ledger paper (17 in. by 11 in.)
* 5 | Legal paper (8.5 in. by 14 in.)
* 6 | Statement paper (5.5 in. by 8.5 in.)
* 7 | Executive paper (7.25 in. by 10.5 in.)
* 8 | A3 paper (297 mm by 420 mm)
* 9 | A4 paper (210 mm by 297 mm)
* 10 | A4 small paper (210 mm by 297 mm)
* 11 | A5 paper (148 mm by 210 mm)
* 12 | B4 paper (250 mm by 353 mm)
* 13 | B5 paper (176 mm by 250 mm)
* 14 | Folio paper (8.5 in. by 13 in.)
* 15 | Quarto paper (215 mm by 275 mm)
* 16 | Standard paper (10 in. by 14 in.)
* 17 | Standard paper (11 in. by 17 in.)
* 18 | Note paper (8.5 in. by 11 in.)
* 19 | #9 envelope (3.875 in. by 8.875 in.)
* 20 | #10 envelope (4.125 in. by 9.5 in.)
* 21 | #11 envelope (4.5 in. by 10.375 in.)
* 22 | #12 envelope (4.75 in. by 11 in.)
* 23 | #14 envelope (5 in. by 11.5 in.)
* 24 | C paper (17 in. by 22 in.)
* 25 | D paper (22 in. by 34 in.)
* 26 | E paper (34 in. by 44 in.)
* 27 | DL envelope (110 mm by 220 mm)
* 28 | C5 envelope (162 mm by 229 mm)
* 29 | C3 envelope (324 mm by 458 mm)
* 30 | C4 envelope (229 mm by 324 mm)
* 31 | C6 envelope (114 mm by 162 mm)
* 32 | C65 envelope (114 mm by 229 mm)
* 33 | B4 envelope (250 mm by 353 mm)
* 34 | B5 envelope (176 mm by 250 mm)
* 35 | B6 envelope (176 mm by 125 mm)
* 36 | Italy envelope (110 mm by 230 mm)
* 37 | Monarch envelope (3.875 in. by 7.5 in.).
* 38 | 6 3/4 envelope (3.625 in. by 6.5 in.)
* 39 | US standard fanfold (14.875 in. by 11 in.)
* 40 | German standard fanfold (8.5 in. by 12 in.)
* 41 | German legal fanfold (8.5 in. by 13 in.)
* 42 | ISO B4 (250 mm by 353 mm)
* 43 | Japanese postcard (100 mm by 148 mm)
* 44 | Standard paper (9 in. by 11 in.)
* 45 | Standard paper (10 in. by 11 in.)
* 46 | Standard paper (15 in. by 11 in.)
* 47 | Invite envelope (220 mm by 220 mm)
* 50 | Letter extra paper (9.275 in. by 12 in.)
* 51 | Legal extra paper (9.275 in. by 15 in.)
* 52 | Tabloid extra paper (11.69 in. by 18 in.)
* 53 | A4 extra paper (236 mm by 322 mm)
* 54 | Letter transverse paper (8.275 in. by 11 in.)
* 55 | A4 transverse paper (210 mm by 297 mm)
* 56 | Letter extra transverse paper (9.275 in. by 12 in.)
* 57 | SuperA/SuperA/A4 paper (227 mm by 356 mm)
* 58 | SuperB/SuperB/A3 paper (305 mm by 487 mm)
* 59 | Letter plus paper (8.5 in. by 12.69 in.)
* 60 | A4 plus paper (210 mm by 330 mm)
* 61 | A5 transverse paper (148 mm by 210 mm)
* 62 | JIS B5 transverse paper (182 mm by 257 mm)
* 63 | A3 extra paper (322 mm by 445 mm)
* 64 | A5 extra paper (174 mm by 235 mm)
* 65 | ISO B5 extra paper (201 mm by 276 mm)
* 66 | A2 paper (420 mm by 594 mm)
* 67 | A3 transverse paper (297 mm by 420 mm)
* 68 | A3 extra transverse paper (322 mm by 445 mm)
* 69 | Japanese Double Postcard (200 mm x 148 mm)
* 70 | A6 (105 mm x 148 mm)
* 71 | Japanese Envelope Kaku #2
* 72 | Japanese Envelope Kaku #3
* 73 | Japanese Envelope Chou #3
* 74 | Japanese Envelope Chou #4
* 75 | Letter Rotated (11in x 8 1/2 11 in)
* 76 | A3 Rotated (420 mm x 297 mm)
* 77 | A4 Rotated (297 mm x 210 mm)
* 78 | A5 Rotated (210 mm x 148 mm)
* 79 | B4 (JIS) Rotated (364 mm x 257 mm)
* 80 | B5 (JIS) Rotated (257 mm x 182 mm)
* 81 | Japanese Postcard Rotated (148 mm x 100 mm)
* 82 | Double Japanese Postcard Rotated (148 mm x 200 mm)
* 83 | A6 Rotated (148 mm x 105 mm)
* 84 | Japanese Envelope Kaku #2 Rotated
* 85 | Japanese Envelope Kaku #3 Rotated
* 86 | Japanese Envelope Chou #3 Rotated
* 87 | Japanese Envelope Chou #4 Rotated
* 88 | B6 (JIS) (128 mm x 182 mm)
* 89 | B6 (JIS) Rotated (182 mm x 128 mm)
* 90 | (12 in x 11 in)
* 91 | Japanese Envelope You #4
* 92 | Japanese Envelope You #4 Rotated
* 93 | PRC 16K (146 mm x 215 mm)
* 94 | PRC 32K (97 mm x 151 mm)
* 95 | PRC 32K(Big) (97 mm x 151 mm)
* 96 | PRC Envelope #1 (102 mm x 165 mm)
* 97 | PRC Envelope #2 (102 mm x 176 mm)
* 98 | PRC Envelope #3 (125 mm x 176 mm)
* 99 | PRC Envelope #4 (110 mm x 208 mm)
* 100 | PRC Envelope #5 (110 mm x 220 mm)
* 101 | PRC Envelope #6 (120 mm x 230 mm)
* 102 | PRC Envelope #7 (160 mm x 230 mm)
* 103 | PRC Envelope #8 (120 mm x 309 mm)
* 104 | PRC Envelope #9 (229 mm x 324 mm)
* 105 | PRC Envelope #10 (324 mm x 458 mm)
* 106 | PRC 16K Rotated
* 107 | PRC 32K Rotated
* 108 | PRC 32K(Big) Rotated
* 109 | PRC Envelope #1 Rotated (165 mm x 102 mm)
* 110 | PRC Envelope #2 Rotated (176 mm x 102 mm)
* 111 | PRC Envelope #3 Rotated (176 mm x 125 mm)
* 112 | PRC Envelope #4 Rotated (208 mm x 110 mm)
* 113 | PRC Envelope #5 Rotated (220 mm x 110 mm)
* 114 | PRC Envelope #6 Rotated (230 mm x 120 mm)
* 115 | PRC Envelope #7 Rotated (230 mm x 160 mm)
* 116 | PRC Envelope #8 Rotated (309 mm x 120 mm)
* 117 | PRC Envelope #9 Rotated (324 mm x 229 mm)
* 118 | PRC Envelope #10 Rotated (458 mm x 324 mm)
*
* @param sheet The worksheet name
* @param opts The page layout options
*/
SetPageLayout(sheet: string, opts: PageLayoutOptions): { error: string | null }
/**
* SetPageMargins provides a function to set worksheet page margins.
* @param sheet The worksheet name
* @param opts The page margin options
*/
SetPageMargins(sheet: string, opts: PageLayoutMarginsOptions): { error: string | null }
/**
* SetPanes provides a function to create and remove freeze panes and split
* panes by given worksheet name and panes format set.
* @param sheet The worksheet name
* @param panes The panes format
*/
SetPanes(sheet: string, panes: Panes): { error: string | null }
/**
* SetRowHeight provides a function to set the height of a single row. If
* the value of height is 0, will hide the specified row, if the value of
* height is -1, will unset the custom row height.
* @param sheet The worksheet name
* @param row The row number
* @param height The height of the row
*/
SetRowHeight(sheet: string, row: number, height : number): { error: string | null }
/**
* SetRowOutlineLevel provides a function to set outline level number of a
* single row by given worksheet name and Excel row number. The value of
* parameter `level` is 1-7.
* @param sheet The worksheet name
* @param row The row number
* @param level The outline level of the row
*/
SetRowOutlineLevel(sheet: string, row: number, level: number): { error: string | null }
/**
* SetRowStyle provides a function to set the style of rows by given
* worksheet name, row range, and style ID. Note that this will overwrite
* the existing styles for the rows, it won't append or merge style with
* existing styles.
* @param sheet The worksheet name
* @param start The start row number
* @param end Then end row number
* @param styleID The style ID
*/
SetRowStyle(sheet: string, start: number, end: number, styleID: number): { error: string | null }
/**
* SetRowVisible provides a function to set visible of a single row by given
* worksheet name and Excel row number. For example, hide row 2 in Sheet1:
*
* ```typescript
* const { error } = f.SetRowVisible('Sheet1', 2, false);
* ```
*
* @param sheet The worksheet name
* @param row The row number
* @param visible The row's visibility
*/
SetRowVisible(sheet: string, row: number, visible: boolean): { error: string | null }
/**
* SetSheetCol writes an array to column by given worksheet name, starting
* cell reference and a pointer to array type 'slice'.
* @param sheet The worksheet name
* @param cell The cell reference
* @param slice The column cells to be write
*/
SetSheetCol(sheet: string, cell: string, slice: Array<boolean | number | string>): { error: string | null }
/**
* SetSheetBackgroundFromBytes provides a function to set background picture
* by given worksheet name, extension name and image data. Supported image
* types: BMP, EMF, EMZ, GIF, JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ.
* @param sheet The worksheet name
* @param extension The extension name
* @param picture The contents buffer of the file
*/
SetSheetBackgroundFromBytes(sheet: string, extension: string, picture: Uint8Array): { error: string | null }
/**
* SetSheetName provides a function to set the worksheet name by given
* source and target worksheet names. Maximum 31 characters are allowed in
* sheet title and this function only changes the name of the sheet and
* will not update the sheet name in the formula or reference associated
* with the cell. So there may be problem formula error or reference
* missing.
* @param source The source sheet name
* @param target The target sheet name
*/
SetSheetName(source: string, target: string): { error: string | null }
/**
* SetSheetProps provides a function to set worksheet properties.
* @param sheet The worksheet name
* @param opts The worksheet property options
*/
SetSheetProps(sheet: string, opts: SheetPropsOptions): { error: string | null }
/**
* SetSheetRow writes an array to row by given worksheet name, starting
* cell reference and a pointer to array type 'slice'.
* @param sheet The worksheet name
* @param cell The starting cell reference
* @param slice The array for writes
*/
SetSheetRow(sheet: string, cell: string, slice: Array<boolean | number | string | null>): { error: string | null }
/**
* SetSheetView sets sheet view options. The viewIndex may be negative and
* if so is counted backward (-1 is the last view).
* @param sheet The worksheet name
* @param viewIndex The sheet view index
* @param opts The sheet view options
*/
SetSheetView(sheet: string, viewIndex: number, opts: ViewOptions): { error: string | null }
/**
* SetSheetVisible provides a function to set worksheet visible by given
* worksheet name. A workbook must contain at least one visible worksheet.
* If the given worksheet has been activated, this setting will be
* invalidated.
* @param sheet The worksheet name
* @param visible The worksheet visibility
*/
SetSheetVisible(sheet: string, visible: boolean): { error: string | null }
/**
* SetWorkbookProps provides a function to sets workbook properties.
* @param opts The workbook property options
*/
SetWorkbookProps(opts: WorkbookPropsOptions): { error: string | null }
/**
* UngroupSheets provides a function to ungroup worksheets.
*/
UngroupSheets(): { error: string | null }
/**
* UnmergeCell provides a function to unmerge a given range reference. For
* example unmerge range reference D3:E9 on Sheet1:
*
* ```typescript
* const { error } = f.UnmergeCell('Sheet1', 'D3', 'E9');
* ```
*
* Attention: overlapped range will also be unmerged.
* @param sheet The worksheet name
* @param topLeftCell The top-left cell reference
* @param bottomRightCell The right-bottom cell reference
*/
UnmergeCell(sheet: string, topLeftCell: string, bottomRightCell: string): { error: string | null }
/**
* UnprotectSheet provides a function to remove protection for a sheet,
* specified the second optional password parameter to remove sheet
* protection with password verification.
* @param sheet The worksheet name
* @param password The password for sheet protection
*/
UnprotectSheet(sheet: string, password?: string): { error: string | null }
/**
* UnprotectWorkbook provides a function to remove protection for workbook,
* specified the optional password parameter to remove workbook protection
* with password verification.
* @param password The password for workbook protection
*/
UnprotectWorkbook(password?: string): { error: string | null }
/**
* UnsetConditionalFormat provides a function to unset the conditional
* format by given worksheet name and range reference.
* @param sheet The worksheet name
* @param reference The conditional format range reference
*/
UnsetConditionalFormat(sheet: string, reference: string): { error: string | null }
/**
* UpdateLinkedValue fix linked values within a spreadsheet are not
* updating in Office Excel application. This function will be remove
* value tag when met a cell have a linked value.
*/
UpdateLinkedValue(): { error: string | null }
/**
* WriteToBuffer provides a function to get the contents buffer from the
* saved file, and it allocates space in memory. Be careful when the file
* size is large.
* @param opts The options for save the spreadsheet
*/
WriteToBuffer(opts?: Options): { buffer: BlobPart, error: string | null };
/**
* Error message
*/
error?: string | null;
}
/**
* init provides a function to compile and instantiate WebAssembly code by a
* given compressed wasm archive path.
* @param path The compressed wasm archive path
*/
export function init(path: string): Promise<{
CellNameToCoordinates: typeof CellNameToCoordinates,
ColumnNameToNumber: typeof ColumnNameToNumber,
ColumnNumberToName: typeof ColumnNumberToName,
CoordinatesToCellName: typeof CoordinatesToCellName,
HSLToRGB: typeof HSLToRGB,
JoinCellName: typeof JoinCellName,
RGBToHSL: typeof RGBToHSL,
SplitCellName: typeof SplitCellName,
ThemeColor: typeof ThemeColor,
NewFile: typeof NewFile;
OpenReader: typeof OpenReader;
CellTypeUnset: typeof CellType.CellTypeUnset;
CellTypeBool: typeof CellType.CellTypeBool;
CellTypeDate: typeof CellType.CellTypeDate;
CellTypeError: typeof CellType.CellTypeError;
CellTypeFormula: typeof CellType.CellTypeFormula;
CellTypeInlineString: typeof CellType.CellTypeInlineString;
CellTypeNumber: typeof CellType.CellTypeNumber;
CellTypeSharedString: typeof CellType.CellTypeSharedString;
CultureNameUnknown: typeof CultureName.CultureNameUnknown;
CultureNameEnUS: typeof CultureName.CultureNameEnUS;
CultureNameJaJP: typeof CultureName.CultureNameJaJP;
CultureNameKoKR: typeof CultureName.CultureNameKoKR;
CultureNameZhCN: typeof CultureName.CultureNameZhCN;
CultureNameZhTW: typeof CultureName.CultureNameZhTW;
FormControlNote: typeof FormControlType.FormControlNote;
FormControlButton: typeof FormControlType.FormControlButton;
FormControlOptionButton: typeof FormControlType.FormControlOptionButton;
FormControlSpinButton: typeof FormControlType.FormControlSpinButton;
FormControlCheckBox: typeof FormControlType.FormControlCheckBox;
FormControlGroupBox: typeof FormControlType.FormControlGroupBox;
FormControlLabel: typeof FormControlType.FormControlLabel;
FormControlScrollBar: typeof FormControlType.FormControlScrollBar;
Area: typeof ChartType.Area;
AreaStacked: typeof ChartType.AreaStacked;
AreaPercentStacked: typeof ChartType.AreaPercentStacked;
Area3D: typeof ChartType.Area3D;
Area3DStacked: typeof ChartType.Area3DStacked;
Area3DPercentStacked: typeof ChartType.Area3DPercentStacked;
Bar: typeof ChartType.Bar;
BarStacked: typeof ChartType.BarStacked;
BarPercentStacked: typeof ChartType.BarPercentStacked;
Bar3DClustered: typeof ChartType.Bar3DClustered;
Bar3DStacked: typeof ChartType.Bar3DStacked;
Bar3DPercentStacked: typeof ChartType.Bar3DPercentStacked;
Bar3DConeClustered: typeof ChartType.Bar3DConeClustered;
Bar3DConeStacked: typeof ChartType.Bar3DConeStacked;
Bar3DConePercentStacked: typeof ChartType.Bar3DConePercentStacked;
Bar3DPyramidClustered: typeof ChartType.Bar3DPyramidClustered;
Bar3DPyramidStacked: typeof ChartType.Bar3DPyramidStacked;
Bar3DPyramidPercentStacked: typeof ChartType.Bar3DPyramidPercentStacked;
Bar3DCylinderClustered: typeof ChartType.Bar3DCylinderClustered;
Bar3DCylinderStacked: typeof ChartType.Bar3DCylinderStacked;
Bar3DCylinderPercentStacked: typeof ChartType.Bar3DCylinderPercentStacked;
Col: typeof ChartType.Col;
ColStacked: typeof ChartType.ColStacked;
ColPercentStacked: typeof ChartType.ColPercentStacked;
Col3D: typeof ChartType.Col3D;
Col3DClustered: typeof ChartType.Col3DClustered;
Col3DStacked: typeof ChartType.Col3DStacked;
Col3DPercentStacked: typeof ChartType.Col3DPercentStacked;
Col3DCone: typeof ChartType.Col3DCone;
Col3DConeClustered: typeof ChartType.Col3DConeClustered;
Col3DConeStacked: typeof ChartType.Col3DConeStacked;
Col3DConePercentStacked: typeof ChartType.Col3DConePercentStacked;
Col3DPyramid: typeof ChartType.Col3DPyramid;
Col3DPyramidClustered: typeof ChartType.Col3DPyramidClustered;
Col3DPyramidStacked: typeof ChartType.Col3DPyramidStacked;
Col3DPyramidPercentStacked: typeof ChartType.Col3DPyramidPercentStacked;
Col3DCylinder: typeof ChartType.Col3DCylinder;
Col3DCylinderClustered: typeof ChartType.Col3DCylinderClustered;
Col3DCylinderStacked: typeof ChartType.Col3DCylinderStacked;
Col3DCylinderPercentStacked: typeof ChartType.Col3DCylinderPercentStacked;
Doughnut: typeof ChartType.Doughnut;
Line: typeof ChartType.Line;
Line3D: typeof ChartType.Line3D;
Pie: typeof ChartType.Pie;
Pie3D: typeof ChartType.Pie3D;
PieOfPie: typeof ChartType.PieOfPie;
BarOfPie: typeof ChartType.BarOfPie;
Radar: typeof ChartType.Radar;
Scatter: typeof ChartType.Scatter;
Surface3D: typeof ChartType.Surface3D;
WireframeSurface3D: typeof ChartType.WireframeSurface3D;
Contour: typeof ChartType.Contour;
WireframeContour: typeof ChartType.WireframeContour;
Bubble: typeof ChartType.Bubble;
Bubble3D: typeof ChartType.Bubble3D;
ChartLineSolid: typeof ChartLineType.ChartLineSolid;
ChartLineNone: typeof ChartLineType.ChartLineNone;
ChartLineAutomatic: typeof ChartLineType.ChartLineAutomatic;
ChartDataLabelsPositionUnset: typeof ChartDataLabelPositionType.ChartDataLabelsPositionUnset;
ChartDataLabelsPositionBestFit: typeof ChartDataLabelPositionType.ChartDataLabelsPositionBestFit;
ChartDataLabelsPositionBelow: typeof ChartDataLabelPositionType.ChartDataLabelsPositionBelow;
ChartDataLabelsPositionCenter: typeof ChartDataLabelPositionType.ChartDataLabelsPositionCenter;
ChartDataLabelsPositionInsideBase: typeof ChartDataLabelPositionType.ChartDataLabelsPositionInsideBase;
ChartDataLabelsPositionInsideEnd: typeof ChartDataLabelPositionType.ChartDataLabelsPositionInsideEnd;
ChartDataLabelsPositionLeft: typeof ChartDataLabelPositionType.ChartDataLabelsPositionLeft;
ChartDataLabelsPositionOutsideEnd: typeof ChartDataLabelPositionType.ChartDataLabelsPositionOutsideEnd;
ChartDataLabelsPositionRight: typeof ChartDataLabelPositionType.ChartDataLabelsPositionRight;
ChartDataLabelsPositionAbove: typeof ChartDataLabelPositionType.ChartDataLabelsPositionAbove;
ChartTickLabelNextToAxis: typeof ChartTickLabelPositionType.ChartTickLabelNextToAxis;
ChartTickLabelHigh: typeof ChartTickLabelPositionType.ChartTickLabelHigh;
ChartTickLabelLow: typeof ChartTickLabelPositionType.ChartTickLabelLow;
ChartTickLabelNone: typeof ChartTickLabelPositionType.ChartTickLabelNone;
}>;
}