Home Index Book Sheet Format Font AutoFilter FilterColumn RichString FormControl
ConditionalFormatting ConditionalFormat CoreProperties Table Examples
ConditionalFormatting ConditionalFormat CoreProperties Table Examples
Book class reference
-
public bool load(string filename)
Loads an entire file into memory. -
public bool load(string filename, string tempFile)
Loads an entire file into memory using a temporary file for reducing memory consumption. -
public bool load(string filename, int sheetIndex)
Loads a file only with the specified sheet index into memory. -
public bool load(string filename, int sheetIndex, string tempFile)
Loads a file only with the specified sheet index into memory using a temporary file for reducing memory consumption. -
public bool load(string filename, int sheetIndex, int firstRow, int lastRow)
Loads a file only with the specified sheet index and row range into memory. -
public bool load(string filename, int sheetIndex, int firstRow, int lastRow, string tempFile)
Loads a file only with the specified sheet index and row range into memory using a temporary file for reducing memory consumption. -
public bool save(string filename)
Saves current workbook into the file. -
public bool save(string filename, bool useTempFile)
Saves current workbook into the file using a temporary file for reducing memory consumption. -
public bool loadWithoutEmptyCells(string filename)
Loads a file without empty cells with formatting information for reducing memory consumption. -
public bool loadInfo(string filename)
Loads only information about sheets. Afterwards you can call Book::sheetCount() and Book::getSheetName() methods. Returns false if error occurs. Get an error info with the Book::errorMessage(). -
public bool loadRaw(byte[] data, int size)
Loads a file from user's memory buffer. Parameters:
data - buffer;
size - size of data in buffer. -
public bool loadRaw(byte[] data, int size, int sheetIndex)
Loads a file only with specified sheet index from user's memory buffer. Parameters:
data - buffer;
size - size of data in buffer;
sheetIndex - sheet index for loading;
-
public bool loadRaw(byte[] data, int size, int sheetIndex, int firstRow, int lastRow)
Loads a file only with specified sheet index and row range from user's memory buffer. Parameters:
data - buffer;
size - size of data in buffer;
sheetIndex - sheet index for loading;
firstRow - the first row of loaded range, -1 loads all rows until lastRow;
lastRow - the last row of loaded range, -1 loads all rows after firstRow.
-
public bool loadInfoRaw(byte[] data, int size)
Loads only information about sheets from user's memory buffer. Afterwards you can call Book::sheetCount() and Book::getSheetName() methods. Parameters:
data - pointer to buffer;
size - size of data in buffer.
Returns false if error occurs. Get an error info with the Book::errorMessage(). -
public bool saveRaw(ref byte[] data, ref int size)
Saves a file to internal memory buffer. Parameters:
data - reference to buffer;
size - reference to saved size.
The memory buffer will be released automatically. -
public void setPassword(string password)
Sets a password for an encrypted workbook. The password must be set before loading a workbook. LibXL supports only xlsx files with ECMA-376 standard and agile encryptions with SHA-1 and SHA-512 hashing algorithms. -
public Sheet addSheet(string name)
Adds a new sheet to this book. You can't use the following characters in sheet names:
- colon (:)
- backslash (\)
- asterisk (*)
- question mark (?)
- forward slash (/)
- opening square bracket ([)
- closing square bracket (])
The sheet name must not begin or end with the single quote (') character. -
public Sheet addSheet(string name, Sheet initSheet)
Adds a new sheet to this book as copy of initSheet. Note initSheet must be only from this book. -
public Sheet insertSheet(int index, string name)
Inserts a new sheet to this book at position index. -
public Sheet insertSheet(int index, string name, Sheet initSheet)
Inserts a new sheet to this book as copy of initSheet at position index. Note initSheet must be only from this book. -
public Sheet getSheet(int index)
Gets a sheet with the specified index. Use the index 0 if used the Book::load() method with sheetIndex parameter. Should be less than a return value of the Book::sheetCount() method. -
public string getSheetName(int index)
Returns a sheet name with the specified index. Returns NULL if error occurs. Get an error info with the Book::errorMessage(). -
public SheetType sheetType(int index)
Returns a type of sheet with the specified index.SheetType value Description SHEETTYPE_SHEET standard sheet SHEETTYPE_CHART chart sheet SHEETTYPE_UNKNOWN unknown sheet -
public bool moveSheet(int srcIndex, int dstIndex)
Takes a sheet with srcIndex and insert it in front of a sheet with dstIndex. Returns false if error occurs. -
public bool delSheet(int index)
Deletes a sheet with the specified index. -
public int sheetCount()
Returns a number of sheets in this book. -
public Format addFormat()
Adds a new format to the workbook. Please note that after loading a file it will be removed. The workbook can't have more than 65429 formats. -
public Format addFormat(Format initFormat)
Adds a new format to the workbook, initial parameters will be copied from other format. Please note that after loading a file it will be removed. The workbook can't have more than 65429 formats. -
public Format addFormatFromStyle(CellStyle style)
Adds a new format to the workbook from the predefined style. Please note that after loading a file it will be removed. The workbook can't have more than 65429 formats.CellStyle value View CELLSTYLE_NORMAL 
CELLSTYLE_BAD 
CELLSTYLE_GOOD 
CELLSTYLE_NEUTRAL 
CELLSTYLE_CALC 
CELLSTYLE_CHECKCELL 
CELLSTYLE_EXPLANATORY 
CELLSTYLE_INPUT 
CELLSTYLE_OUTPUT 
CELLSTYLE_HYPERLINK 
CELLSTYLE_LINKEDCELL 
CELLSTYLE_NOTE 
CELLSTYLE_WARNING 
CELLSTYLE_TITLE 
CELLSTYLE_HEADING1 
CELLSTYLE_HEADING2 
CELLSTYLE_HEADING3 
CELLSTYLE_HEADING4 
CELLSTYLE_TOTAL 
CELLSTYLE_20ACCENT1 
CELLSTYLE_40ACCENT1 
CELLSTYLE_60ACCENT1 
CELLSTYLE_ACCENT1 
CELLSTYLE_20ACCENT2 
CELLSTYLE_40ACCENT2 
CELLSTYLE_60ACCENT2 
CELLSTYLE_ACCENT2 
CELLSTYLE_20ACCENT3 
CELLSTYLE_40ACCENT3 
CELLSTYLE_60ACCENT3 
CELLSTYLE_ACCENT3 
CELLSTYLE_20ACCENT4 
CELLSTYLE_40ACCENT4 
CELLSTYLE_60ACCENT4 
CELLSTYLE_ACCENT4 
CELLSTYLE_20ACCENT5 
CELLSTYLE_40ACCENT5 
CELLSTYLE_60ACCENT5 
CELLSTYLE_ACCENT5 
CELLSTYLE_20ACCENT6 
CELLSTYLE_40ACCENT6 
CELLSTYLE_60ACCENT6 
CELLSTYLE_ACCENT6 
CELLSTYLE_COMMA Comma CELLSTYLE_COMMA0 Comma [0] CELLSTYLE_CURRENCY Currency CELLSTYLE_CURRENCY0 Currency [0] CELLSTYLE_PERCENT Percent -
public Font addFont()
Adds a new font to the workbook. The workbook can't have more than 504 fonts for xls files and 65429 fonts for xlsx files. -
public Font addFont(Font initFont)
Adds a new font to the workbook, initial parameters will be copied from other font. The workbook can't have more than 504 fonts for xls files and 65429 fonts for xlsx files. -
public RichString addRichString()
Adds a new rich string to the workbook for using different fonts in a single cell with the Sheet::writeRichStr() method. -
public int addCustomNumFormat(string customNumFormat)
Adds a new custom number format to the workbook. The format string customNumFormat indicates how to format and render the numeric value of a cell. See custom format strings guidelines. Returns the custom format identifier. It's used in Format::setNumFormat(). -
public string customNumFormat(int fmt)
Returns a custom format string for specified custom format identifier fmt. See custom format string guidelines. -
public Format format(int index)
Returns a format with defined index. Index must be less than return value of formatSize() method. -
public int formatSize()
Returns a number of formats in this book. -
public Font font(int index)
Returns a font with defined index. Index must be less than return value of fontSize() method. -
public int fontSize()
Returns a number of fonts in this book. -
public ConditionalFormat addConditionalFormat()
Adds a new conditional format to the workbook for using with conditional formatting rules (only for xlsx files). -
public ConditionalFormat conditionalFormat(int index)
Returns a conditional format with defined index. Index must be less than return value of conditionalFormatSize() method. -
public int conditionalFormatSize()
Returns a number of conditional formats in this book. -
public double datePack(int year, int month, int day)
Packs date information into double type. -
public double datePack(int year, int month, int day, int hour, int min, int sec)
Packs date and time information into double type. -
public double datePack(int year, int month, int day, int hour, int min, int sec, int msec)
Packs date and time with milliseconds into double type. -
public bool dateUnpack(double value, ref int year, ref int month, ref int day)
Unpacks date information from double type. -
public bool dateUnpack(double value, ref int year, ref int month, ref int day, ref int hour, ref int min, ref int sec)
Unpacks date and time information from double type. -
public bool dateUnpack(double value, ref int year, ref int month, ref int day, ref int hour, ref int min, ref int sec, ref int msec)
Unpacks date and time with milliseconds from double type. -
public Color colorPack(int red, int green, int blue)
Packs red, green and blue components in color type. -
public void colorUnpack(Color color, ref int red, ref int green, ref int blue)
Unpacks color type to red, green and blue components. -
public int activeSheet()
Returns an active sheet index in this workbook. -
public void setActiveSheet(int index)
Sets an active sheet index in this workbook. -
public int pictureSize()
Returns a number of pictures in this workbook. -
public PictureType getPicture(int index, ref byte[] data, ref int size)
Returns a picture at position index in memory buffer. Parameters:
index - position in the workbook;
data - reference to buffer;
size - reference to saved size.
Returns type of picture:PictureType value Description PICTURETYPE_PNG PNG format PICTURETYPE_JPEG JPEG format PICTURETYPE_GIF GIF format PICTURETYPE_WMF WMF format PICTURETYPE_DIB DIB format PICTURETYPE_EMF EMF format PICTURETYPE_TIFF TIFF format -
public int addPicture(string filename)
Adds a picture to the workbook. Returns a picture identifier. Supports BMP, DIB, PNG, JPG and WMF picture formats. Use picture identifier with Sheet::setPicture(). -
public int addPicture2(byte[] data, int size)
Adds a picture to the workbook from memory buffer:
data - byte array with picture data (BMP, DIB, PNG, JPG or WMF formats);
size - size of array.
Returns a picture identifier. Use picture identifier with Sheet::setPicture(). -
public int addPictureAsLink(string filename, bool insert)
Adds a picture to the workbook as link (only for xlsx files):
insert = false - stores only a link to file;
insert = true - stores a picture and a link to file.
Returns a picture identifier. Supports BMP, DIB, PNG, JPG and WMF picture formats. Use picture identifier with Sheet::setPicture(). Returns -1 if error occurs. -
public string defaultFont(ref int fontSize)
Returns a default font name and size for this workbook. -
public void setDefaultFont(string fontName, int fontSize)
Sets a default font name and size for this workbook. -
public bool refR1C1
R1C1 reference mode property: true if mode is active and false if isn't. -
public bool rgbMode
RGB mode: true - RGB mode, false - Index mode (default). If true then use colorPack() and colorUnpack() methods for getting/setting colors. -
public bool calcMode
The calculation mode of workbook:CalcModeType value Description CALCMODE_MANUAL manual calculation CALCMODE_AUTO automatic calculation CALCMODE_AUTONOTABLE automatic except for data tables -
public int version
Returns the version of the used LibXL library in hexadecimal numeral system. -
public int biffVersion
Returns BIFF version of binary file. Used for xls format only. -
public bool date1904
The date system mode: true - 1904 date system, false - 1900 date system (default).
In the 1900 date base system, the lower limit is January 1, 1900, which has serial value 1.
In the 1904 date base system, the lower limit is January 1, 1904, which has serial value 0. -
public bool template
The template flag: true - workbook is template, false - workbook is not template (default).
This property must have a value "true" for template files (xlt and xltx). -
public bool isWriteProtected
Returns whether the workbook is marked as read-only. -
public CoreProperties coreProperties()
Returns workbook properties. -
public bool removeVBA()
Removes all VBA scripts (macros) from the workbook. It should be called after loading xlsm or xlsb files. Returns true if VBA scripts were found and removed. -
public bool removePrinterSettings()
Removes all printer settings from the workbook. It should be called after loading an Excel file. Returns true if printer settings were found and removed. -
public void removeAllPhonetics()
Removes all phonetics data (furigana) from a workbook. -
public void clear()
Removes all data from a workbook. -
public void setKey(string name, string key)
Sets customer's license key.