SimpleXlsx  r0.19
 All Classes Namespaces Functions Variables Enumerations Pages
SimpleXlsx::CWorksheet Class Reference

The class CWorksheet is used for creation and population .xlsx file sheet table with data. More...

#include <Worksheet.h>

Public Member Functions

 CWorksheet ()
 The class default constructor.
 CWorksheet (uint32_t index, const _tstring &temp_path)
 The class constructor.
 CWorksheet (uint32_t index, std::vector< ColumnWidth > &colHeights, const _tstring &temp_path)
 The class constructor.
 CWorksheet (uint32_t index, uint32_t width, uint32_t height, const _tstring &temp_path)
 The class constructor to create sheet with frozen pane.
 CWorksheet (uint32_t index, uint32_t width, uint32_t height, std::vector< ColumnWidth > &colHeights, const _tstring &temp_path)
 The class constructor to create sheet with frozen pane.
virtual ~CWorksheet ()
 The class destructor (virtual)
void BeginRow (uint32_t height=0)
 Generates a header for another row.
void AddCell (const CellDataStr &data)
 Add string-formatted cell with specified style.
void AddCells (const std::vector< CellDataStr > &data)
 Adds a group of cells into a row.
void AddCell (const CellDataTime &data)
 Add time-formatted cell with specified style.
void AddCells (const std::vector< CellDataTime > &data)
 Adds a group of cells into a row.
void EndRow ()
 Closes previously began row.
void AddRow (const std::vector< CellDataStr > &data, uint32_t offset=0, uint32_t height=0)
 Appends another row into the sheet.
void AddRow (const std::vector< CellDataTime > &data, uint32_t offset=0, uint32_t height=0)
 Appends another row into the sheet.
void AddRow (const std::vector< CellDataInt > &data, uint32_t offset=0, uint32_t height=0)
 Appends another row into the sheet.
void AddRow (const std::vector< CellDataUInt > &data, uint32_t offset=0, uint32_t height=0)
 Appends another row into the sheet.
void AddRow (const std::vector< CellDataDbl > &data, uint32_t offset=0, uint32_t height=0)
 Appends another row into the sheet.
void AddRow (const std::vector< CellDataFlt > &data, uint32_t offset=0, uint32_t height=0)
 Appends another row into the sheet.
void MergeCells (CellCoord cellFrom, CellCoord cellTo)
 Appends merged cells range into the sheet.
void GetCurrentCellCoord (CellCoord &currCell)
 Receives next to write cell`s coordinates.
bool Save ()
 Saves current xml document into a file with preset name.

Static Public Member Functions

static void GetCellCoord (CellCoord cell, TCHAR *szCoord)
 Transforms the row and the column numerics from int32_t to coordinate string format.

Private Member Functions

void Init (uint32_t index, uint32_t frozenWidth, uint32_t frozenHeight, std::vector< ColumnWidth > &colHeights)
 Initializes internal variables and creates a header of a sheet xml tree.
void AddFrozenPane (uint32_t width, uint32_t height)
 Internal initializatino method adds frozen pane`s information into sheet.
template<typename T >
void AddCellRoutine (T data, int32_t style)
 Appends another a group of cells into a row.
bool SaveCommentsRels ()
 Saves current sheet relations file.

Private Attributes

_tofstream * m_f
 stl output file stream is used for xml writing
xmlw::XmlStream * m_xmlStream
 xml output stream
std::vector< _tstring > m_calcChain
 list of cells with formulae
std::map< _tstring, uint64_t > * m_sharedStrings
 pointer to the list of string supposed to be into shared area
std::vector< Comment > * m_comments
 pointer to the list of comments
std::vector< _tstring > m_mergedCells
 list of merged cells` ranges (e.g. A1:B2)
int32_t m_index
 current sheet number
_tstring m_temp_path
 path to the temporary directory (unique for a book)
_tstring m_title
 page title
bool m_withFormula
 indicates whether the sheet contains formulae
bool m_withComments
 indicates whether the sheet contains any comments
bool m_isOk
 indicates initialization successfulness
bool m_isDataPresented
 indicates whether the sheet contains a data
int32_t m_row_index
 since data add row-by-row it contains current row to write
bool m_row_opened
 indicates whether row tag is opened
int32_t m_current_column
 used at separate row generation - last cell column number to be added
int32_t m_offset_column
 used at entire row addition (implicit parameter for AddCell method)
EPageOrientation m_page_orientation
 defines page orientation for printing

Detailed Description

The class CWorksheet is used for creation and population .xlsx file sheet table with data.

Constructor & Destructor Documentation

SimpleXlsx::CWorksheet::CWorksheet ( )

The class default constructor.

Returns
no
Note
The constructor creates an instance with sheet1.xml filename and without any frozen panes
SimpleXlsx::CWorksheet::CWorksheet ( uint32_t  index,
const _tstring &  temp_path 
)

The class constructor.

Parameters
indexindex of a sheet to be created (for example, sheet1.xml)
temp_pathpath to the temporary directory where sheet files must be created
Returns
no
Note
The constructor creates an instance with specified sheetX.xml filename and without any frozen panes
SimpleXlsx::CWorksheet::CWorksheet ( uint32_t  index,
std::vector< ColumnWidth > &  colWidths,
const _tstring &  temp_path 
)

The class constructor.

Parameters
indexindex of a sheet to be created (for example, sheet1.xml)
colWidthslist of pairs colNumber:Width
temp_pathpath to the temporary directory where sheet files must be created
Returns
no
Note
The constructor creates an instance with specified sheetX.xml filename and without any frozen panes
SimpleXlsx::CWorksheet::CWorksheet ( uint32_t  index,
uint32_t  width,
uint32_t  height,
const _tstring &  temp_path 
)

The class constructor to create sheet with frozen pane.

Parameters
indexindex of a sheet to be created (for example, sheet1.xml)
widthfrozen pane with
heightfrozen pane height
temp_pathpath to the temporary directory where sheet files must be created
Returns
no
SimpleXlsx::CWorksheet::CWorksheet ( uint32_t  index,
uint32_t  width,
uint32_t  height,
std::vector< ColumnWidth > &  colWidths,
const _tstring &  temp_path 
)

The class constructor to create sheet with frozen pane.

Parameters
indexindex of a sheet to be created (for example, sheet1.xml)
widthfrozen pane with
heightfrozen pane height
colWidthslist of pairs colNumber:Width
temp_pathpath to the temporary directory where sheet files must be created
Returns
no
SimpleXlsx::CWorksheet::~CWorksheet ( )
virtual

The class destructor (virtual)

Returns
no

Member Function Documentation

void SimpleXlsx::CWorksheet::AddCell ( const CellDataStr data)

Add string-formatted cell with specified style.

Parameters
datareference to data
Returns
no
void SimpleXlsx::CWorksheet::AddCell ( const CellDataTime data)

Add time-formatted cell with specified style.

Parameters
datareference to data
Returns
no
template<typename T >
void SimpleXlsx::CWorksheet::AddCellRoutine ( data,
int32_t  style 
)
private

Appends another a group of cells into a row.

Parameters
datatemplate data value
stylestyle index
Returns
no
void SimpleXlsx::CWorksheet::AddCells ( const std::vector< CellDataStr > &  data)
inline

Adds a group of cells into a row.

Parameters
datareference to the vector of pairs <string, style_index>
Returns
no
void SimpleXlsx::CWorksheet::AddCells ( const std::vector< CellDataTime > &  data)
inline

Adds a group of cells into a row.

Parameters
datareference to the vector of pairs <time_t, style_index>
Returns
no
void SimpleXlsx::CWorksheet::AddFrozenPane ( uint32_t  width,
uint32_t  height 
)
private

Internal initializatino method adds frozen pane`s information into sheet.

Parameters
widthfrozen pane width (in number of cells)
heightfrozen pane height (in number of cells)
Returns
no
void SimpleXlsx::CWorksheet::AddRow ( const std::vector< CellDataStr > &  data,
uint32_t  offset = 0,
uint32_t  height = 0 
)

Appends another row into the sheet.

Parameters
datareference to the vector of pairs <string, style>
offsetthe offset from the row begining (0 by default)
heightrow height (deafult if 0)
Returns
no
void SimpleXlsx::CWorksheet::AddRow ( const std::vector< CellDataTime > &  data,
uint32_t  offset = 0,
uint32_t  height = 0 
)

Appends another row into the sheet.

Parameters
datareference to the vector of pairs <string, style>
offsetthe offset from the row begining (0 by default)
heightrow height (deafult if 0)
Returns
no
void SimpleXlsx::CWorksheet::AddRow ( const std::vector< CellDataInt > &  data,
uint32_t  offset = 0,
uint32_t  height = 0 
)

Appends another row into the sheet.

Parameters
datareference to the vector of pairs <int32_t, style>
offsetthe offset from the row begining (0 by default)
heightrow height (deafult if 0)
Returns
no
void SimpleXlsx::CWorksheet::AddRow ( const std::vector< CellDataUInt > &  data,
uint32_t  offset = 0,
uint32_t  height = 0 
)

Appends another row into the sheet.

Parameters
datareference to the vector of pairs <uint32_t, style>
offsetthe offset from the row begining (0 by default)
heightrow height (deafult if 0)
Returns
no
void SimpleXlsx::CWorksheet::AddRow ( const std::vector< CellDataDbl > &  data,
uint32_t  offset = 0,
uint32_t  height = 0 
)

Appends another row into the sheet.

Parameters
datareference to the vector of pairs <double, style>
offsetthe offset from the row begining (0 by default)
heightrow height (deafult if 0)
Returns
no
void SimpleXlsx::CWorksheet::AddRow ( const std::vector< CellDataFlt > &  data,
uint32_t  offset = 0,
uint32_t  height = 0 
)

Appends another row into the sheet.

Parameters
datareference to the vector of pairs <float, style>
offsetthe offset from the row begining (0 by default)
heightrow height (deafult if 0)
Returns
no
void SimpleXlsx::CWorksheet::BeginRow ( uint32_t  height = 0)
inline

Generates a header for another row.

Parameters
heightrow height (default if 0)
Returns
no
void SimpleXlsx::CWorksheet::EndRow ( )
inline

Closes previously began row.

Returns
no
void SimpleXlsx::CWorksheet::GetCellCoord ( CellCoord  cell,
TCHAR *  szCoord 
)
static

Transforms the row and the column numerics from int32_t to coordinate string format.

Parameters
cell(row value from 1, col value from 0)
szCoordoutput parameter to be filled (pointer must be valid)
Returns
no
void SimpleXlsx::CWorksheet::GetCurrentCellCoord ( CellCoord currCell)

Receives next to write cell`s coordinates.

Parameters
currCell(row value from 1, col value from 0)
Returns
no
void SimpleXlsx::CWorksheet::Init ( uint32_t  index,
uint32_t  frozenWidth,
uint32_t  frozenHeight,
std::vector< ColumnWidth > &  colWidths 
)
private

Initializes internal variables and creates a header of a sheet xml tree.

Parameters
indexindex of a sheet to be created (for example, sheet1.xml)
frozenWidthfrozen pane with
frozenHeightfrozen pane height
colWidthslist of pairs colNumber:Width
Returns
no
void SimpleXlsx::CWorksheet::MergeCells ( CellCoord  cellFrom,
CellCoord  cellTo 
)

Appends merged cells range into the sheet.

Parameters
cellFrom(row value from 1, col value from 0)
cellTo(row value from 1, col value from 0)
Returns
no
bool SimpleXlsx::CWorksheet::Save ( )

Saves current xml document into a file with preset name.

Returns
Boolean result of the operation
bool SimpleXlsx::CWorksheet::SaveCommentsRels ( )
private

Saves current sheet relations file.

Returns
no

The documentation for this class was generated from the following files: