NumberDuck v1.2.1 [J332] API Reference

Workbook

Provides read/write access to Excel .xls files.

Workbook(const char* szRegistrationKey)
~Workbook()
void Clear()
bool Load(const char* szFileName)
bool Save(const char* szFileName)
uint16_t GetNumWorksheet()
Worksheet* GetWorksheetByIndex(unsigned int nIndex)
Worksheet* CreateWorksheet()
void PurgeWorksheet(unsigned int nIndex)
uint16_t GetNumStyle()
Style* GetStyleByIndex(uint16_t nIndex)
Style* GetDefaultStyle()
Style* CreateStyle()


Worksheet

Provides access to cells and other stuff of a worksheet.

const char* GetName()
bool SetName(const char* szName)
uint16_t GetColumnWidth(uint16_t nColumn)
void SetColumnWidth(uint16_t nColumn, uint16_t nWidth)
void InsertColumn(uint16_t nColumn)
void DeleteColumn(uint16_t nColumn)
uint16_t GetRowHeight(uint16_t nRow)
void SetRowHeight(uint16_t nRow, uint16_t nHeight)
void InsertRow(uint16_t nRow)
void DeleteRow(uint16_t nRow)
Cell* GetCellByAddress(const char* szAddress)
Cell* GetCell(uint16_t nX, uint16_t nY)
uint16_t GetNumPicture()
Picture* GetPictureByIndex(uint16_t nIndex)
Picture* CreatePicture(const char* szFileName)
void PurgePicture(uint16_t nIndex)


Cell

Cell objects give access to the properties of a single cell.

bool Equals(const FileScribe::Cell* pCell) const
Cell::Type GetType()
void Clear()
void SetString(const char* szString)
const char* GetString()
void SetFloat(double fFloat)
double GetFloat()
void SetBoolean(bool bBoolean)
bool GetBoolean()
void SetFormula(const char* szFormula)
const char* GetFormula()
Style* GetStyle()
bool SetStyle(Style* pStyle)


Style

Used for styling cells.

const char* GetFont()
void SetFont(const char* szFont)
uint8_t GetSize()
void SetSize(uint8_t nSize)
const Color* GetColor()
void SetColor(const Color color)
void ClearColor()
bool GetBold()
void SetBold(bool bBold)
bool GetItalic()
void SetItalic(bool bItalic)
Style::Underline GetUnderline()
void SetUnderline(FileScribe::Style::Underline eUnderline eUnderline)
const Color* GetBackgroundColor()
void SetBackgroundColor(const Color color)
void ClearBackgroundColor()


Color

RGB color information. Used by the Style class.

Color(uint8_t nRed, uint8_t nGreen, uint8_t nBlue)
bool Equals(const FileScribe::Color* pColor) const
uint8_t GetRed() const
void SetRed(uint8_t nRed)
uint8_t GetGreen() const
void SetGreen(uint8_t nGreen)
uint8_t GetBlue() const
void SetBlue(uint8_t nBlue)
uint32_t GetRgba() const


Picture

Represents an embedded picture inside a worksheet.

uint16_t GetX()
bool SetX(uint16_t nX)
uint16_t GetY()
bool SetY(uint16_t nY)
uint16_t GetSubX()
void SetSubX(uint16_t nSubX)
uint16_t GetSubY()
void SetSubY(uint16_t nSubY)
uint16_t GetWidth()
void SetWidth(uint16_t nWidth)
uint16_t GetHeight()
void SetHeight(uint16_t nHeight)
const uint8_t* GetData()
uint32_t GetDataSize()
Picture::Format GetFormat()


Workbook

Provides read/write access to Excel .xls files.

Workbook(const char* szRegistrationKey)

Unassuming constructor.

If you have purchased Number Duck, pass in your registration key here to remove annoying watermarks, otherwise just pass in an empty string or NULL.

~Workbook()

Resolute destructor.

void Clear()

Clears this workbook back to defaults. The same result as deleting the object and constructing it again.

bool Load(const char* szFileName)

Loads a .xls file from disk.

Currently only simple Excel .xls formatted files are supported.

Returns false on error.

A common error in loading is that the file is locked because it is already open in Excel.

bool Save(const char* szFileName)

Saves the current workbook to disk in Excel .xls format.

Returns false on error.

Eg: pWorkbook->Save("BananaReport.xls");

uint16_t GetNumWorksheet()

Returns the number of worksheets available.

Worksheet* GetWorksheetByIndex(unsigned int nIndex)

Returns a pointer to the Worksheet from the given index.

Returns NULL if the given index is out of range.

Worksheet* CreateWorksheet()

Creates a new Worksheet and returns a pointer to it.

If the workbook already has the maximum allowed number of worksheets, this function returns null.

void PurgeWorksheet(unsigned int nIndex)

Deletes the Worksheet at the given index.

uint16_t GetNumStyle()

Returns the number of created styles available.

More styles may be created with the CreateStyle function.

Style* GetStyleByIndex(uint16_t nIndex)

Returns the Style at the given index.

Returns NULL if you give an out of range index like a silly person.

Style* GetDefaultStyle()

Returns the default Style for this Workbook.

This is a simple wrapper for GetStyleByIndex(0).

Style* CreateStyle()

Creates a new style and returns a pointer to it.

Using this pointer you can set all the pretties.

Worksheet

Provides access to cells and other stuff of a worksheet.

const char* GetName()

Returns the name of the worksheet in UTF8.

bool SetName(const char* szName)

Sets the name of the worksheet. Returns false if the name is already in use by another Worksheet.

szName is a UTF8 string.

uint16_t GetColumnWidth(uint16_t nColumn)

Returns the width of the given column in pixels.

void SetColumnWidth(uint16_t nColumn, uint16_t nWidth)

Sets the width of the column in pixels.

void InsertColumn(uint16_t nColumn)

Inserts a column before the given one.

The 255th column is removed to make room for it.

void DeleteColumn(uint16_t nColumn)

Deletes the given column.

uint16_t GetRowHeight(uint16_t nRow)

Returns the height of the given row in pixels.

void SetRowHeight(uint16_t nRow, uint16_t nHeight)

Sets the pixel height of the given row of the worksheet.

void InsertRow(uint16_t nRow)

Inserts a row before the given one.

The 65535th row is removed to make room for it.

void DeleteRow(uint16_t nRow)

Deletes the given row.

Cell* GetCellByAddress(const char* szAddress)

Returns the Cell at the address given.

Eg: pWorksheet->GetCell("B5");

Cell* GetCell(uint16_t nX, uint16_t nY)

Returns the Cell at the zero based coordinates given.

Eg: pWorkSheet->GetCell(1, 4); // same as pWorksheet->GetCell("B5");

uint16_t GetNumPicture()

Returns the number of pictures embedded in this worksheet.

Picture* GetPictureByIndex(uint16_t nIndex)

Returns a pointer to the Picture from the given index.

Returns NULL if the given index is out of range.

Picture* CreatePicture(const char* szFileName)

Creates a new Picture and returns a pointer to it.

szFileName is the path to a PNG or JPEG file.

Returns NULL if szFileName file cannout be found or is the wrong format.

void PurgePicture(uint16_t nIndex)

Deletes the Picture at the given index.

Cell

Cell objects give access to the properties of a single cell. This is all pretty straightforward right?

bool Equals(const FileScribe::Cell* pCell) const

Comparison function, returns true if this cell matches the one given.

Eg: If both cells contain the same number.

Cell::Type GetType()

Returns the type of the contents of this cell.

Possible types are:

void Clear()

Clears this cell back to a pristine untouched state.

void SetString(const char* szString)

Stores the given string in the cell.

A cell may only store a single type of value at a time, eg: string, float, boolean, formula etc.

const char* GetString()

Returns the string stored in this cell.

If the cell type is not TYPESTRING this function will return an empty string. Use _GetType to check.

void SetFloat(double fFloat)

Stores the given float in the cell.

A cell may only store a single type of value at a time, eg: string, float, boolean, formula etc.

double GetFloat()

Returns the float stored in this cell.

If the cell type is not TYPEFLOAT this function will return 0.0. Use _GetType to check.

void SetBoolean(bool bBoolean)

Stores the given boolean in the cell.

A cell may only store a single type of value at a time, eg: string, float, boolean, formula etc.

bool GetBoolean()

Returns the boolean stored in this cell.

If the cell type is not TYPEBOOLEAN this function will return false. Use _GetType to check.

void SetFormula(const char* szFormula)

Stores the given formula in the cell.

A cell may only store a single type of value at a time, eg: string, float, boolean, formula etc.

Eg: pCell->SetFormula("=SUM(A1:A5)");

const char* GetFormula()

Returns the formula stored in this cell. The formula will be prefixed with "=".

If the cell type is not TYPEFORMULA this function will return "=". Use _GetType to check.

Style* GetStyle()

Gets the current custom Style applied to this cell.

Compare with Workbook::GetDefaultStyle() to see if this cell is using default styling.

bool SetStyle(Style* pStyle)

Sets the Style used by this cell.

Use Workbook::CreateStyle to create a new style.

Or use Cell::GetStyle or Workbook::GetStyleByIndex to use an existing style.

Returns false on error, usually if you try to pass in a NULL pointer or a Style that comes from a different workbook.

Style

Used for styling cells.

Use Workbook::CreateStyle to create a new style.

Or use Cell::GetStyle or Workbook::GetStyleByIndex to use an existing style.

const char* GetFont()

Returns the name of the current font face used by this Style.

void SetFont(const char* szFont)

Sets the font face to be used by this Style.

Eg: pStyle->SetFont("Comic Sans MS");

uint8_t GetSize()

Returns the font size, in pixels, used by this Style.

void SetSize(uint8_t nSize)

Sets the font size of this Style, in pixels.

Eg: pStyle->SetSize(10);

const Color* GetColor()

Returns the current font color.

void SetColor(const Color color)

Sets the font color to be used by this Style.

Eg: pStyle->SetColor(FileScribe::Color(0xFF, 0x00, 0xFF));

void ClearColor()

Clears the font color to be used by this Style back to the default.

The default is usually black, but may be different based on the users system settings when viewing the spreadsheet.

bool GetBold()

Returns the emboldment status for this Style.

void SetBold(bool bBold)

Used to set whether the font used by this Style is bold or not.

Eg: pStyle->SetBold(true);

bool GetItalic()

Returns true if the font used by this Style is italicized.

void SetItalic(bool bItalic)

Used to set whether the font used by this Style is italic or not.

Eg: pStyle->SetItalic(true);

Style::Underline GetUnderline()

Returns the type of underline used by this _Style.

Possible types are:

void SetUnderline(FileScribe::Style::Underline eUnderline eUnderline)

Sets the type of underline used by this Style.

See Style::GetUnderline for the list of possible underline types.

Eg: pStyle->SetUnderline(FileScribe::Style::UNDERLINE_SINGLE);

const Color* GetBackgroundColor()

Returns the background color.

void SetBackgroundColor(const Color color)

Sets the background color.

Eg: pStyle->SetBackgroundColor(FileScribe::Color(0x00, 0x00, 0xFF));

void ClearBackgroundColor()

Clears the background color.

Note that clear is different from white. The white comes from the users system settings so it could in fact be any color.

Color

RGB color information. Used by the Style class.

Color(uint8_t nRed, uint8_t nGreen, uint8_t nBlue)

Constructor.

Eg: pStyle->SetColor(FileScribe::Color(0x00, 0xFF, 0x00));

bool Equals(const FileScribe::Color* pColor) const

Returns true if this Color matches the one given.

uint8_t GetRed() const

Returns the red value of this color.

void SetRed(uint8_t nRed)

Sets the red value of this color.

uint8_t GetGreen() const

Returns the green value of this color.

void SetGreen(uint8_t nGreen)

Sets the red value of this color.

uint8_t GetBlue() const

Returns the blue value of this color.

void SetBlue(uint8_t nBlue)

Sets the blue value of this color.

uint32_t GetRgba() const

Returns the this color as a 32bit RGBA int.

Picture

Represents an embedded picture inside a worksheet.

Use Workbook::CreatePicture to create a new picture from an image on disk. Or use Workbook::GetPictureByIndex to get an existing picture.

Pictures can only be created from PNG or JPEG files. Existing pictures already embedded in the spreadsheet can be any format.

uint16_t GetX()

Returns the column where the top left corner of the picture is anchored.

bool SetX(uint16_t nX)

Sets the column where top left corner of the picture is anchored.

Returns false if an out of bounds column is given.

uint16_t GetY()

Returns the row where the top left corner of the picture is anchored.

bool SetY(uint16_t nY)

Sets the row where top left corner of the picture is anchored.

Returns false if an out of bounds row is given.

uint16_t GetSubX()

Returns the horizontal pixel offset of the picture within the cell given by GetX() and GetY().

void SetSubX(uint16_t nSubX)

Sets the horizontal pixel offset of this picture inside the cell.

uint16_t GetSubY()

Returns the vertical pixel offset of the picture within the cell given by GetX() and GetY().

void SetSubY(uint16_t nSubY)

Sets the vertical pixel offset of this picture inside the cell.

uint16_t GetWidth()

Returns the width of the pitcure, in pixels.

void SetWidth(uint16_t nWidth)

Sets the width of the picture, in pixels.

uint16_t GetHeight()

Returns the height of the pitcure, in pixels.

void SetHeight(uint16_t nHeight)

Sets the height of the picture, in pixels.

const uint8_t* GetData()

Returns the binary data for this image.

See GetFormat() for what image format this data is in.

uint32_t GetDataSize()

Returns the size of the binary data returned by GetData().

Picture::Format GetFormat()

Returns the image format of the data given by GetData().

Possible types are: