Sheet class reference
-
CellType cellType(unsigned short row, unsigned short 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(unsigned short row, unsigned short col) const
Checks that cell contains a formula.
-
Format* cellFormat(unsigned short row, unsigned short col) const
Returns cell's format. It can be changed by user.
-
void setCellFormat(unsigned short row, unsigned short col, Format* format)
Sets cell's format.
-
const wchar_t* readStr(unsigned short row, unsigned short 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(unsigned short row, unsigned short 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(unsigned short row, unsigned short 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(unsigned short row, unsigned short 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(unsigned short row, unsigned short 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(unsigned short row, unsigned short 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(unsigned short row, unsigned short 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(unsigned short row, unsigned short col, Format* format)
Writes blank cell with specified format. Returns false if error occurs. Get error info with Book::errorMessage().
-
const wchar_t* readFormula(unsigned short row, unsigned short 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(unsigned short row, unsigned short 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(unsigned short row, unsigned short col) const
Reads a comment from specified cell.
-
void writeComment(unsigned short row, unsigned short 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(unsigned short row, unsigned short col) const
Checks that cell contains a date or time value.
-
ErrorType readError(unsigned short row, unsigned short 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(unsigned short col) const
Returns column width.
-
double rowHeight(unsigned short row) const
Returns row height.
-
bool setCol(unsigned short colFirst, unsigned short 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(unsigned short 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(unsigned short row, unsigned short col, unsigned short* rowFirst, unsigned short* rowLast, unsigned short* colFirst, unsigned short* 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(unsigned short rowFirst, unsigned short rowLast, unsigned short colFirst, unsigned short colLast)
Sets merged cells for range: rowFirst - rowLast, colFirst - colLast. Returns false if error occurs. Get error info with Book::errorMessage().
-
bool delMerge(unsigned short row, unsigned short col)
-
void setPicture(unsigned short row, unsigned short 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(unsigned short row, unsigned short 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(unsigned short row, bool pageBreak = true)
Sets/removes a horizontal page break. Returns false if error occurs. Get error info with Book::errorMessage().
-
bool setVerPageBreak(unsigned short col, bool pageBreak = true)
Sets/removes a vertical page break. Returns false if error occurs. Get error info with Book::errorMessage().
-
void split(unsigned short row, unsigned short col)
Splits a sheet at position (row, col).
-
bool groupRows(unsigned short rowFirst, unsigned short rowLast, bool collapsed = true)
Groups rows from rowFirst to rowLast. Returns false if error occurs. Get error info with Book::errorMessage().
-
bool groupCols(unsigned short colFirst, unsigned short colLast, bool collapsed = true)
Groups columns from colFirst to colLast. Returns false if error occurs. Get error info with Book::errorMessage().
-
void clear(unsigned short rowFirst = 0, unsigned short rowLast = 65535, unsigned short colFirst = 0, unsigned short colLast = 255)
Clears cells in specified area.
-
bool insertRow(unsigned short rowFirst, unsigned short rowLast)
Inserts rows from rowFirst to rowLast. Returns false if error occurs. Get error info with Book::errorMessage().
-
bool insertCol(unsigned short colFirst, unsigned short colLast)
Inserts columns from colFirst to colLast. Returns false if error occurs. Get error info with Book::errorMessage().
-
bool removeRow(unsigned short rowFirst, unsigned short rowLast)
Removes rows from rowFirst to rowLast. Returns false if error occurs. Get error info with Book::errorMessage().
-
bool removeCol(unsigned short colFirst, unsigned short colLast)
Removes columns from colFirst to colLast. Returns false if error occurs. Get error info with Book::errorMessage().
-
bool copyCell(unsigned short rowSrc, unsigned short colSrc, unsigned short rowDst, unsigned short 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.
-
unsigned zoom() const
Returns the zoom level of the current view as a percentage.
-
void setZoom(unsigned zoom)
Sets the zoom level of the current view. 100 is a usual view.
-
unsigned printZoom() const
Returns the scaling factor for printing as a percentage.
-
void setPrintZoom(unsigned 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
-
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
-
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.
-
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.
|