LibXL: Sheet class reference

LibXL excel library for developers
- Index Book Sheet Format Font ### Sheet class reference CellType cellType(int row, int col) const Returns cell's type.
  CellType value | Description
  CELLTYPE_EMPTY | empty
  CELLTYPE_NUMBER | number value
  CELLTYPE_STRING | string value
  CELLTYPE_BOOLEAN | boolean value
  CELLTYPE_BLANK | blank
  CELLTYPE_ERROR | error
- bool isFormula(int row, int col) const Checks that cell contains a formula. Format* cellFormat(int row, int col) const Returns cell's format. It can be changed by user. void setCellFormat(int row, int col, Format* format) Sets cell's format. const wchar_t* readStr(int row, int col, Format** format = 0) Reads a string and its format from cell. Memory is allocated internally and valid until a new workbook is loaded or Book::release() is called. Returns NULL if specified cell doesn't contain string or error occurs. Get error info with Book::errorMessage(). bool writeStr(int row, int col, const wchar_t* value, Format* format = 0) Writes a string into cell with specified format. If format equals 0 then format is ignored. String is copied internally and can be destroyed after call this method. Returns false if error occurs. Get error info with Book::errorMessage(). double readNum(int row, int col, Format** format = 0) const Reads a number or date/time and its format from cell. Use Book::dateUnpack() for extract date/time parts from double. If *format == 0 then error occurs. Get error info with Book::errorMessage(). bool writeNum(int row, int col, double value, Format* format = 0) Writes a number or date/time into cell with specified format. If format equals 0 then format is ignored. Use Book::datePack() for packing date/time parts to double. Returns false if error occurs. Get error info with Book::errorMessage(). bool readBool(int row, int col, Format** format = 0) const Reads a bool value and its format from cell. If *format == 0 then error occurs. Get error info with Book::errorMessage(). bool writeBool(int row, int col, bool value, Format* format = 0) const Writes a bool value into cell with specified format. If format equals 0 then format is ignored. Returns false if error occurs. Get error info with Book::errorMessage(). bool readBlank(int row, int col, Format** format = 0) const Reads format from blank cell. Returns false if specified cell isn't blank or error occurs. Get error info with Book::errorMessage(). bool writeBlank(int row, int col, Format* format) Writes blank cell with specified format. Returns false if error occurs. Get error info with Book::errorMessage(). const wchar_t* readFormula(int row, int col, Format** format = 0) Reads a formula string and its format from cell. Returns NULL if specified cell doesn't contain formula or error occurs. Get error info with Book::errorMessage(). bool writeFormula(int row, int col, const wchar_t* value, Format* format = 0) Writes a formula into cell with specified format. If format equals 0 then format is ignored. Returns false if error occurs. Get error info with Book::errorMessage(). const wchar_t* readComment(int row, int col) const Reads a comment from specified cell. void writeComment(int row, int col, const wchar_t* value, const wchar_t* author = 0, int width = 129, int height = 75) Writes a comment to the cell. Parameters: (row, col) - cell's position; value - comment string; author - author string; width - width of text box in pixels; height - height of text box in pixels. bool isDate(int row, int col) const Checks that cell contains a date or time value. ErrorType readError(int row, int col) const Reads error from cell.
  ErrorType value | Description
  ERRORTYPE_NULL | #NULL!
  ERRORTYPE_DIV_0 | #DIV/0!
  ERRORTYPE_VALUE | #VALUE!
  ERRORTYPE_REF | #REF!
  ERRORTYPE_NAME | #NAME?
  ERRORTYPE_NUM | #NUM!
  ERRORTYPE_NA | #N/A
  ERRORTYPE_NOERROR | no error
- double colWidth(int col) const Returns column width. double rowHeight(int row) const Returns row height. bool setCol(int colFirst, int colLast, double width, Format* format = 0, bool hidden = false) Sets column width and format for all columns from colFirst to colLast. If format equals 0 then format is ignored. Columns may be hidden. Returns false if error occurs. Get error info with Book::errorMessage(). bool setRow(int row, double height, Format* format = 0, bool hidden = false) Sets row height and format. If format equals 0 then format is ignored. Row may be hidden. Returns false if error occurs. Get error info with Book::errorMessage(). bool getMerge(int row, int col, int* rowFirst, int* rowLast, int* colFirst, int* colLast) Gets merged cells for cell at row, col. Result is written in rowFirst, rowLast, colFirst, colLast. Returns false if error occurs. Get error info with Book::errorMessage(). bool setMerge(int rowFirst, int rowLast, int colFirst, int colLast) Sets merged cells for range: rowFirst - rowLast, colFirst - colLast. Returns false if error occurs. Get error info with Book::errorMessage(). bool delMerge(int row, int col) Removes merged cells. Returns false if error occurs. Get error info with Book::errorMessage(). void setPicture(int row, int col, int pictureId, double scale = 1.0) Sets a picture with pictureId identifier at position row and col with scale factor. Use Book::addPicture() for getting picture identifier. void setPicture2(int row, int col, int pictureId, int width, int height) Sets a picture with pictureId identifier at position row and col with custom size. Use Book::addPicture() for getting a picture identifier. bool setHorPageBreak(int row, bool pageBreak = true) Sets/removes a horizontal page break. Returns false if error occurs. Get error info with Book::errorMessage(). bool setVerPageBreak(int col, bool pageBreak = true) Sets/removes a vertical page break. Returns false if error occurs. Get error info with Book::errorMessage(). void split(int row, int col) Splits a sheet at position (row, col). bool groupRows(int rowFirst, int rowLast, bool collapsed = true) Groups rows from rowFirst to rowLast. Returns false if error occurs. Get error info with Book::errorMessage(). bool groupCols(int colFirst, int colLast, bool collapsed = true) Groups columns from colFirst to colLast. Returns false if error occurs. Get error info with Book::errorMessage(). bool groupSummaryBelow() const Returns whether grouping rows summary is below. Returns true if summary is below and false if isn't. void setGroupSummaryBelow(bool below) Sets a flag of grouping rows summary: true - below, false - above. bool groupSummaryRight() const Returns whether grouping columns summary is right. Returns true if summary is right and false if isn't. void setGroupSummaryRight(bool right) Sets a flag of grouping rows summary: true - right, false - left. void clear(int rowFirst = 0, int rowLast = 65535, int colFirst = 0, int colLast = 255) Clears cells in specified area. bool insertRow(int rowFirst, int rowLast) Inserts rows from rowFirst to rowLast. Returns false if error occurs. Get error info with Book::errorMessage(). bool insertCol(int colFirst, int colLast) Inserts columns from colFirst to colLast. Returns false if error occurs. Get error info with Book::errorMessage(). bool removeRow(int rowFirst, int rowLast) Removes rows from rowFirst to rowLast. Returns false if error occurs. Get error info with Book::errorMessage(). bool removeCol(int colFirst, int colLast) Removes columns from colFirst to colLast. Returns false if error occurs. Get error info with Book::errorMessage(). bool copyCell(int rowSrc, int colSrc, int rowDst, int colDst) Copies cell with format from (rowSrc, colSrc) to (rowDst, colDst). Returns false if error occurs. Get error info with Book::errorMessage(). int firstRow() const Returns the first row in the sheet that contains a used cell. int lastRow() const Returns the zero-based index of the row after the last row in the sheet that contains a used cell. int firstCol() const Returns the first column in the sheet that contains a used cell. int lastCol() const Returns the zero-based index of the column after the last column in the sheet that contains a used cell. bool displayGridlines() const Returns whether the gridlines are displayed. Returns true if gridlines are displayed and false if aren't. void setDisplayGridlines(bool show = true) Sets gridlines for displaying, true - gridlines are displayed, false - gridlines aren't displayed. bool printGridlines() const Returns whether the gridlines are printed. Return true if gridlines are printed and false if aren't. void setPrintGridlines(bool print = true) Sets gridlines for printing, true - gridlines are printed, false - gridlines aren't printed. int zoom() const Returns the zoom level of the current view as a percentage. void setZoom(int zoom) Sets the zoom level of the current view. 100 is a usual view. int printZoom() const Returns the scaling factor for printing as a percentage. void setPrintZoom(int zoom) Sets the scaling factor for printing as a percentage. bool landscape() const Returns a page orientation mode, true - landscape mode, false - portrait mode. void setLandscape(bool landscape = true) Sets landscape or portrait mode for printing, true - pages are printed using landscape mode, false - pages are printed using portrait mode. Paper paper() const Retrurns the paper size. void setPaper(Paper paper = PAPER_DEFAULT) Sets the paper size.
  Paper value | Description
  PAPER_DEFAULT | Default paper size
  PAPER_LETTER | US Letter 8 1/2 x 11 in
  PAPER_LETTERSMALL | US Letter Small 8 1/2 x 11 in
  PAPER_TABLOID | US Tabloid 11 x 17 in
  PAPER_LEDGER | US Ledger 17 x 11 in
  PAPER_LEGAL | US Legal 8 1/2 x 14 in
  PAPER_STATEMENT | US Statement 5 1/2 x 8 1/2 in
  PAPER_EXECUTIVE | US Executive 7 1/4 x 10 1/2 in
  PAPER_A3 | A3 297 x 420 mm
  PAPER_A4 | A4 210 x 297 mm
  PAPER_A4SMALL | A4 Small 210 x 297 mm
  PAPER_A5 | A5 148 x 210 mm
  PAPER_B4 | B4 (JIS) 250 x 354
  PAPER_B5 | B5 (JIS) 182 x 257 mm
  PAPER_FOLIO | Folio 8 1/2 x 13 in
  PAPER_QUATRO | Quarto 215 x 275 mm
  PAPER_10x14 | 10 x 14 in
  PAPER_10x17 | 11 x 17 in
  PAPER_NOTE | US Note 8 1/2 x 11 in
  PAPER_ENVELOPE_9 | US Envelope #9 3 7/8 x 8 7/8
  PAPER_ENVELOPE_10 | US Envelope #10 4 1/8 x 9 1/2
  PAPER_ENVELOPE_11 | US Envelope #11 4 1/2 x 10 3/8
  PAPER_ENVELOPE_12 | US Envelope #12 4 3/4 x 11
  PAPER_ENVELOPE_14 | US Envelope #14 5 x 11 1/2
  PAPER_C_SIZE | C size sheet
  PAPER_D_SIZE | D size sheet
  PAPER_E_SIZE | E size sheet
  PAPER_ENVELOPE_DL | Envelope DL 110 x 220mm
  PAPER_ENVELOPE_C5 | Envelope C5 162 x 229 mm
  PAPER_ENVELOPE_C3 | Envelope C3 324 x 458 mm
  PAPER_ENVELOPE_C4 | Envelope C4 229 x 324 mm
  PAPER_ENVELOPE_C6 | Envelope C6 114 x 162 mm
  PAPER_ENVELOPE_C65 | Envelope C65 114 x 229 mm
  PAPER_ENVELOPE_B4 | Envelope B4 250 x 353 mm
  PAPER_ENVELOPE_B5 | Envelope B5 176 x 250 mm
  PAPER_ENVELOPE_B6 | Envelope B6 176 x 125 mm
  PAPER_ENVELOPE | Envelope 110 x 230 mm
  PAPER_ENVELOPE_MONARCH | US Envelope Monarch 3.875 x 7.5 in
  PAPER_US_ENVELOPE | US Envelope 3 5/8 x 6 1/2 in
  PAPER_FANFOLD | US Std Fanfold 14 7/8 x 11 in
  PAPER_GERMAN_STD_FANFOLD | German Std Fanfold 8 1/2 x 12 in
  PAPER_GERMAN_LEGAL_FANFOLD | German Legal Fanfold 8 1/2 x 13 in
- const wchar_t* header() const Returns the header text of the sheet when printed. Get error info with Book::errorMessage(). bool setHeader(const wchar_t* header, double margin = 0.5) Sets the header text of the sheet when printed. The text appears at the top of every page when printed. The length of the text must be less than or equal to 255. The header text can contain special commands, for example a placeholder for the page number, current date or text formatting attributes. Special commands are represented by single letter with a leading ampersand ("&"). Margin is specified in inches.
  Code | Description
  &L | specifies the beginning of the left section
  &P | specifies the current page number
  &N | specifies the total number of pages
  &\d{1,3} | specifies the text font size, where font size is measured in points, for example: &9 or &36
  &S | specifies whether the strikethrough text style is on or off
  &X | specifies whether the superscript text style is on or off
  &Y | specifies whether the subscript text style is on or off
  &C | specifies the beginning of the center section
  &D | specifies a date
  &T | specifies a time
  &G | specifies a picture
  &U | specifies whether the single underline text style is on or off
  &E | specifies whether the double underline text style is on or off
  &R | specifies the beginning of the right section
  &Z | specifies a workbook file path
  &F | specifies a workbook file name
  &A | specifies a sheet name
  &"fontname" | specifies the text font, for example: &"Comic Sans MS"
  &B | specifies whether the bold text style is on or off
  &I | specifies whether the italic text style is on or off
  && | specifies an ampersand character (&)
double headerMargin() const Returns the header margin in inches. const wchar_t* footer() const Returns the footer text of the sheet when printed. Get error info with Book::errorMessage(). bool setFooter(const wchar_t* footer, double margin = 0.5) Sets the footer text for the sheet when printed. The footer text appears at the bottom of every page when printed. The length of the text must be less than or equal to 255. The footer text can contain special commands, for example a placeholder for the page number, current date or text formatting attributes. See setHeader for details. Margin is specified in inches. double footerMargin() const Returns the footer margin in inches. bool hCenter() const Returns whether the sheet is centered horizontally when printed. void setHCenter(bool hCenter = true) Sets a flag that the sheet is centered horizontally when printed. bool vCenter() const Returns whether the sheet is centered vertically when printed. void setVCenter(bool vCenter = true) Sets a flag that the sheet is centered vertically when printed. double marginLeft() const Returns the left margin of the sheet in inches. void setMarginLeft(double margin) Sets the left margin of the sheet in inches. double marginRight() const Returns the right margin of the sheet in inches. void setMarginRight(double margin) Sets the right margin of the sheet in inches. double marginTop() const Returns the top margin of the sheet in inches. void setMarginTop(double margin) Sets the top margin of the sheet in inches. double marginBottom() const Returns the bottom margin of the sheet in inches. void setMarginBottom(double margin) Sets the bottom margin of the sheet in inches. bool printRowCol() const Returns whether the row and column headers are printed. void setPrintRowCol(bool print = true) Sets a flag that the row and column headers are printed. void setPrintRepeatRows(int rowFirst, int rowLast) Sets repeated rows on each page from rowFirst to rowLast. void setPrintRepeatCols(int colFirst, int colLast) Sets repeated columns on each page from colFirst to colLast. void setPrintArea(int rowFirst, int rowLast, int colFirst, int colLast) Sets the print area. void clearPrintRepeats() Clears repeated rows and columns on each page. void clearPrintArea() Clears the print area. bool setNamedRange(const wchar_t* name, int rowFirst, int rowLast, int colFirst, int colLast) Sets the named range. Returns false if error occurs. Get error info with Book::errorMessage(). bool delNamedRange(const wchar_t* name) Deletes the named range by name. Returns false if error occurs. Get error info with Book::errorMessage(). const wchar_t* name() const Returns the name of the sheet. void setName(const wchar_t* name) Sets the name of the sheet. bool protect() const Returns whether sheet is protected. void setProtect(bool protect = true) Protects/unprotects the sheet. Index Book Sheet Format Font