LibXL API reference version 3.8.3
- Index Book Sheet Format Font AutoFilter FilterColumn ### Book class reference bool load(const wchar_t* filename, const wchar_t* tempFile = 0) Loads an entire file into memory. Specify a temporary file for reducing memory consumption. Returns false if error occurs. Get error info with Book::errorMessage(). bool loadSheet(const wchar_t* filename, int sheetIndex, const wchar_t* tempFile = 0) Loads a file only with specified sheet index into memory. Specify a temporary file for reducing memory consumption. Returns false if error occurs. Get error info with Book::errorMessage(). bool loadPartially(const wchar_t* filename, int sheetIndex, int firstRow, int lastRow, const wchar_t* tempFile = 0) Loads a file only with specified sheet index and row range into memory. Specify a temporary file for reducing memory consumption. Returns false if error occurs. Get error info with Book::errorMessage(). bool save(const wchar_t* filename, bool useTempFile = false) Saves current workbook into the file. Use a temporary file for reducing memory consumption. Returns false if error occurs. Get error info with Book::errorMessage(). bool loadWithoutEmptyCells(const wchar_t* filename) Loads only cells which contain values. Empty formatted cells will be ignored for reducing memory consumption. Works only for binary xls files. Returns false if error occurs. Get error info with Book::errorMessage(). bool loadInfo(const wchar_t* filename) Loads only information about sheets. Afterwards you can call Book::sheetCount() and Book::getSheetName() methods. Returns false if error occurs. Get error info with Book::errorMessage(). bool loadRaw(const char* data, unsigned size, int sheetIndex = -1, int firstRow = -1, int lastRow = -1) Loads a file from user's memory buffer. Parameters: data - pointer to buffer; size - size of data in buffer; sheetIndex - loads a file only with specified sheet index, -1 loads all sheets; 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. Returns false if error occurs. Get error info with Book::errorMessage(). bool saveRaw(const char** data, unsigned* size) Saves a file to internal memory buffer. Parameters: data - pointer to buffer; size - pointer to saved size. Returns false if error occurs. Get error info with Book::errorMessage(). Sheet* addSheet(const wchar_t* name, Sheet* initSheet = 0) Adds a new sheet to this book, returns the sheet pointer. Use initSheet parameter if you wish to copy an existing sheet. Note initSheet must be only from 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. Returns NULL if error occurs. Get error info with Book::errorMessage(). Sheet* insertSheet(int index, const wchar_t* name, Sheet* initSheet = 0) Inserts a new sheet to this book at position index, returns the sheet pointer. Use initSheet parameter if you wish to copy an existing sheet. Note initSheet must be only from this book. Returns NULL if error occurs. Get error info with Book::errorMessage(). Sheet* getSheet(int index) const Gets pointer to a sheet with specified index. Returns NULL if error occurs. Get error info with Book::errorMessage(). const wchar_t* getSheetName(int index) const Returns a sheet name with specified index. Returns NULL if error occurs. Get error info with Book::errorMessage(). SheetType sheetType(int index) const Returns type of sheet with specified index.
  SheetType value | Description
  SHEETTYPE_SHEET | standard sheet
  SHEETTYPE_CHART | chart sheet
  SHEETTYPE_UNKNOWN | unknown sheet
- bool moveSheet(int srcIndex, int dstIndex) Moves a sheet with specified index to a new position. Returns false if error occurs. Get error info with Book::errorMessage(). bool delSheet(int index) Deletes a sheet with specified index. Returns false if error occurs. Get error info with Book::errorMessage(). int sheetCount() const Returns a number of sheets in this book. Format* addFormat(Format* initFormat = 0) Adds a new format to the workbook, initial parameters can be copied from other format. Returns NULL if error occurs. Font* addFont(Font* initFont = 0) Adds a new font to the workbook, initial parameters can be copied from other font. Returns NULL if error occurs. int addCustomNumFormat(const wchar_t* 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(). Returns 0 if error occurs. Get error info with Book::errorMessage(). const wchar_t* customNumFormat(int fmt) const Returns a custom format string for specified custom format identifier fmt. See custom format string guidelines. Returns NULL if error occurs. Get error info with Book::errorMessage(). Format* format(int index) Returns a format with defined index. Index must be less than return value of formatSize() method. int formatSize() Returns a number of formats in this book. Font* font(int index) Returns a font with defined index. Index must be less than return value of fontSize() method. int fontSize() Returns a number of fonts in this book. double datePack(int year, int month, int day, int hour = 0, int min = 0, int sec = 0, int msec = 0) Packs date and time information into double type. bool dateUnpack(double value, int* year, int* month, int* day, int* hour = 0, int* min = 0, int* sec = 0, int* msec = 0) Unpacks date and time information from double type. Returns false if error occurs. Color colorPack(int red, int green, int blue) Packs red, green and blue components in color type. void colorUnpack(Color color, int* red, int* green, int* blue) Unpacks color type to red, green and blue components. int activeSheet() const Returns an active sheet index in this workbook. void setActiveSheet(int index) Sets an active sheet index in this workbook. int pictureSize() const Returns a number of pictures in this workbook. PictureType getPicture(int index, const char** data, unsigned* size) const 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_WMF | WMF format
  PICTURETYPE_DIB | DIB format
  PICTURETYPE_EMF | EMF format
  PICTURETYPE_TIFF | TIFF format
  PICTURETYPE_ERROR | Get error info with Book::errorMessage()
int addPicture(const wchar_t* 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(). Returns -1 if error occurs. Get error info with Book::errorMessage(). int addPicture2(const char* data, unsigned size) Adds a picture to the workbook from memory buffer: data - pointer to buffer with picture data (BMP, DIB, PNG, JPG or WMF formats); size - size of data in buffer. Returns a picture identifier. Use picture identifier with Sheet::setPicture(). Returns -1 if error occurs. Get error info with Book::errorMessage(). int addPictureAsLink(const wchar_t* filename, bool insert = false) 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. Get error info with Book::errorMessage(). const wchar_t* defaultFont(int* fontSize) Returns a default font name and size for this workbook. Returns 0 if error occurs. Get error info with Book::errorMessage(). void setDefaultFont(const wchar_t* fontName, int fontSize) Sets a default font name and size for this workbook. bool refR1C1() const Returns whether the R1C1 reference mode is active. void setRefR1C1(bool refR1C1 = true) Sets the R1C1 reference mode. bool rgbMode() Returns whether the RGB mode is active. void setRgbMode(bool rgbMode = true) Sets a RGB mode: true - RGB mode, false - Index mode (default). In RGB mode use colorPack() and colorUnpack() methods for getting/setting colors. int biffVersion() const Returns BIFF version of binary file. Used for xls format only. bool isDate1904() const Returns whether the 1904 date system is active. void setDate1904(bool date1904 = true) Sets 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. bool isTemplate() const Returns whether the workbook is template. void setTemplate(bool tmpl = true) Sets the template flag: true - workbook is template, false - workbook is not template (default). It allows to change type of file from a template file (xlt and xltx) to a regular file (xls and xlsx) and vice versa. void setKey(const wchar_t* name, const wchar_t* key) Sets customer's license key. bool setLocale(const char* locale) Sets the locale for this library. The locale argument is the same as the locale argument in setlocale() function from C Run-Time Library. For example, value "en_US.UTF-8" allows to use non-ascii characters in Linux or Mac. It accepts the special value "UTF-8" for using UTF-8 character encoding in Windows and other operating systems. It has no effect for unicode projects with wide strings (with _UNICODE preprocessor variable). Returns true if a valid locale argument is given. const char* errorMessage() const Returns the last error message. void release() Deletes this object and free resources. Index Book Sheet Format Font AutoFilter FilterColumn