OfficeSheet

 

class OfficeSheet : public SheetPlugin, public StaticPlugin

 

OfficeSheet class serves to manage spreadsheets made with OpenOffice Calc or Microsoft Office Excel.

The class methods are designed to be as simple as possible and are exactly the same for both suites.

OfficeSheet handles the suites through "Ole Automation" so it requires either OpenOffice or Microsoft Office to be previosly installed in the computer.

 

 

Constructor detail

 

OfficeSheet()

OfficeSheet constructor. It has no arguments as in function Init() it is defined which Office suite is going to be used.

 

 

Public Method List

 

~OfficeSheet()

OfficeSheet destructor. It closes spreadsheet application.

 


 

bool IsAvailable(const char *type)

It checks if office suit of name type.is available to be init.

Valid values are "Open" and "Microsoft".

 


 

bool SetSaved(bool saved)

Sets or unsets the flag saved, so that the application did not ask for saving the document if the application receives the Quit() order.

 


 

bool Init(const char *type)

Initializes OfficeSheet to use type.suite.

Valid values are "Open" and "Microsoft".

 


 

bool AddSheet(bool visible)

Opens a new spreadsheet. If visible.is true the spreadsheet application will be visible. If not all the rest of operations made over the spreadsheet will be hidden for the user.

 


 

bool OpenSheet(String fileName, bool visible)

Opens an existing spreadsheet file whose name is fileName. If visible is true the spreadsheet application will be visible. If not all the rest of operations made over the spreadsheet will be hidden for the user.

 


 

bool SetValue(int col, int row, Value value)

Fills cell col, row with the value value. col, row origin is (1, 1). value is inserted using the most adequate format depending on the value type.

value can be a function.

 


 

bool SetValue(String cell, Value value)

Fills cell cell with the value value. cell is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets. value is inserted using the most adequate format depending on the value type.

value can be a function.

 


 

bool SetValue(Value value)

Fills the range previously selected by Select() with value. value is inserted using the most adequate format depending on the value type.

value can be a function.

 


 

Value GetValue(int col, int row)

Returns the value got in cell col, row. col, row origin is (1, 1).

 


 

Value GetText(int col, int row)

Returns the result of the the formula form cell col, row. col, row origin is (1, 1).

 


 

Value GetValue(String cell)

Returns the value got in cell cell. cell is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets.

 


 

bool Replace(Value search, Value replace)

Replaces value search with value replace.in the selected range by Select() or all the document.

 


 

bool SetBold(int col, int row, bool bold)

Sets or unsets cell bold letters in col, row. col, row origin is (1, 1).

 


 

bool SetBold(String cell, bool bold)

Sets or unsets cell bold letters in cell. cell is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets.

 


 

bool SetBold(bool bold)

Sets or unsets cell bold letters in the selected range by Select() or all the document.

 


 

bool SetItalic(int col, int row, bool italic)

Sets or unsets cell italic letters in col, row. col, row origin is (1, 1).

 


 

bool SetItalic(String cell, bool italic)

Sets or unsets cell italic letters in cell. cell is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets.

 


 

bool SetItalic(bool italic)

Sets or unsets cell italic letters in the selected range by Select() or all the document.

 


 

bool SetUnderline(bool underline)

Sets or unsets cell underline letters in the selected range by Select() or all the document.

 


 

bool SetUnderline(String cell, bool underline)

Sets or unsets cell underline letters in cell. cell is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets.

 


 

bool SetUnderline(int col, int row, bool underline)

Sets or unsets cell underlined letters in col, row. col, row origin is (1, 1).

 


 

bool SetFont(int col, int row, String name, int size)

Sets in cell col, row font name with size in points. cell is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets.

 


 

bool SetFont(String cell, String name, int size)

Sets in cell font name with size in points. col, row origin is (1, 1).

 


 

bool SetFont(String name, int size)

Sets the selected range by Select() or all the document with font name with size in points.

 


 

bool SetColor(int col, int row, Color color)

Sets or unsets cell letter color in col, row. col, row origin is (1, 1).

 


 

bool SetColor(String cell, Color color)

Sets or unsets cell letter color in cell. cell is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets.

 


 

bool SetColor(Color color)

Sets or unsets cell letter color in the selected range by Select() or all the document.

 


 

bool SetBackColor(int col, int row, Color color)

Sets or unsets cell background color in col, row. col, row origin is (1, 1).

 


 

bool SetBackColor(String cell, Color color)

Sets or unsets cell letter background color in cell. cell is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets.

 


 

bool SetBackColor(Color color)

Sets or unsets cell letter background color in the selected range by Select() or all the document.

 


 

bool SetRowHeight(int row, double height)

Sets row height in millimeters.

 


 

bool SetColWidth(int col, double width)

Sets col width in millimeters.

 


 

bool SetHorizAlignment(String cell, int alignment)

Sets cell horizontal alignment. cell is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets.

alignment is a constant that can be LEFT, CENTER, RIGHT or JUSTIFY.

 


 

bool SetHorizAlignment(int col, int row, int alignment)

Sets cell horizontal alignment in col, row. col, row origin is (1, 1).

alignment is a constant that can be LEFT, CENTER, RIGHT or JUSTIFY.

 


 

bool SetVertAlignment(String cell, int alignment)

Sets cell vertical alignment. cell is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets.

alignment is a constant that can be TOP, CENTER or BOTTOM.

 


 

bool SetVertAlignment(int col, int row, int alignment)

Sets cell vertical alignment in col, row. col, row origin is (1, 1).

alignment is a constant that can be TOP, CENTER or BOTTOM.

 


 

bool SetBorder(int borderIndx, int lineStyle, int weight, Color color)

Sets selected cells border type, where:

borderIndx is the changed border. Values are BORDER_DIAG_DOWN, BORDER_DIAG_UP, BORDER_LEFT, BORDER_TOP, BORDER_BOTTOM and BORDER_RIGHT.

lineStyle is the line style. Values are NONE, CONTINUOUS, DASH, DASHDOT and DOT.

weight is the line thickness. Values are HAIRLINE, MEDIUM, THIN and THICK.

color is the border color.

It is not implemented in Open/LibreOffice.

 


 

bool SetBorder(int col, int row, int borderIndx, int lineStyle, int weight, Color color)

Sets cell col and row border type, where:

borderIndx is the changed border. Values are BORDER_DIAG_DOWN, BORDER_DIAG_UP, BORDER_LEFT, BORDER_TOP, BORDER_BOTTOM and BORDER_RIGHT.

lineStyle is the line style. Values are NONE, CONTINUOUS, DASH, DASHDOT and DOT.

weight is the line thickness. Values are HAIRLINE, MEDIUM, THIN and THICK.

color is the border color.

It is not implemented in Open/LibreOffice.

 


 

bool Select(String range)

Selects range. range is a string that indicates the range location with letters to indicate the column and a number to indicate the row of the top left and bottom right vertex as in "B7:D9", following the format used in spreadsheets.

 


 

bool Select(int fromX, int fromY, int toX, int toY)

Selects range from top left vertex fromX, fromY to right bottom toX, toY. Origin is (1, 1).

 


 

virtual bool MatrixAllocate(int width, int height)

Allocates width, height data for matriz operations.

It is not implemented in Open/LibreOffice.

 


 

virtual bool MatrixDelete()

Deletes the matrix object.

It is not implemented in Open/LibreOffice.

 


 

virtual bool MatrixFillSelection()

Fills the selected range with matrix data.

It is not implemented in Open/LibreOffice.

 


 

bool MatrixSet(int fromX, int fromY, Vector<Vector<Value> > &data)

Fills with data matrix from top left vertex fromX, fromY. Origin is (1, 1).

This operation is much faster than using SetValue().

Open/LibreOffice version retrieves data cell by cell.

 


 

virtual bool MatrixSetValue(int x, int y, ::Value value)

Sets cell x, y with value value.

 


 

bool MatrixGet(int fromX, int fromY, int width, int height, Vector<Vector<Value> > &data)

Retrieves data  from top left vertex fromX, fromY with range width, height.

This operation is much faster than using GetValue().

Open/LibreOffice version retrieves data cell by cell.

 


 

bool Select()

Selects full sheet.

 


 

bool Print()

Prints the selected spreadsheet.

 


 

bool SaveAs(String fileName, String type = "xls")

Saves the opened fileName with format type.

Formats admitted depend on the implementation but are basically:

    OpenOffice:     "xls", "pxl", "html", "txt", "pdf" and "ods".

    Microsoft:     "csv", "html", "txt", "xlsx" and "xls"


 

bool Quit()

Closes the spreadsheet application.

    It is also called by the class destructor

 


 

bool InsertTab(String name)

Inserts a new tab with name.

 


 

bool ChooseTab(String name)

Makes active tab with name.

 


 

bool ChooseTab(int index)

Makes active tab with index, beginning from 1.

 


 

bool RemoveTab(String name)

Remove tab with name.

 


 

bool RemoveTab(int index)

Removes tab with index, beginning from 1.

 


 

int GetNumTabs()

Gets the number of tabs.

 


 

String GetType()

Returns the spreadsheet type.

Valid values are:

"Open"

"Microsoft"

 


 

static void CellToColRow(const char *cell, int &col, int &row)

Converts cell into col and row. cell is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets. col, row origin is (1, 1)

 


 

static String ColRowToCell(const int col, const int row)

Returns the cell in text represented by col, row. Cell returned is a string that indicates the cell location with letters to indicate the column and a number to indicate the row as in "B7", following the format used in spreadsheets. col, row origin is (1, 1)