62 #define SIZEOFWCHAR_T 2
64 #define SIZEOFWCHAR_T sizeof(wchar_t)
76 bool Create(
const wchar_t* filename);
77 bool Open(
const wchar_t* filename, std::ios_base::openmode mode=std::ios_base::in | std::ios_base::out);
82 bool Read(
size_t index,
char* block);
83 bool Write(
size_t index,
const char* block);
84 bool Swap(
size_t index1,
size_t index2);
85 bool Move(
size_t from,
size_t to);
86 bool Insert(
size_t index,
const char* block);
87 bool Erase(
size_t index);
88 bool Erase(std::vector<size_t>& indices);
109 template<
typename Type>
110 static void Read(
const char* buffer,
Type& retVal,
int pos=0,
int bytes=0)
113 if (bytes == 0) bytes =
sizeof(
Type);
114 for (
size_t i=0; i < (size_t)bytes; ++i)
116 retVal |= ((
Type)((
unsigned char)buffer[pos+i])) << 8*i;
120 template<
typename Type>
123 for (
size_t i = 0; i < (size_t)bytes; ++i)
Read(buffer, str[i], pos+i*
sizeof(
Type));
126 template<
typename Type>
127 static void Write(
char* buffer,
Type val,
int pos=0,
int bytes=0)
129 if (bytes == 0) bytes =
sizeof(
Type);
130 for (
size_t i = 0; i < (size_t)bytes; ++i)
132 buffer[pos+i] = (
unsigned char)val;
137 template<
typename Type>
140 for (
size_t i = 0; i < (size_t)bytes; ++i)
Write(buffer, str[i], pos+i*
sizeof(
Type));
143 template<
typename Type>
144 static void Read(
const std::vector<char>& buffer,
Type& retVal,
int pos=0,
int bytes=0)
147 if (bytes == 0) bytes =
sizeof(
Type);
148 for (
size_t i = 0; i < (size_t)bytes; ++i)
150 retVal |= ((
Type)((
unsigned char)buffer[pos+i])) << 8*i;
154 template<
typename Type>
155 static void ReadString(
const std::vector<char>& buffer,
Type* str,
int pos=0,
int bytes=0)
157 for (
size_t i = 0; i < (size_t)bytes; ++i)
Read(buffer, str[i], pos+i*
sizeof(
Type));
160 template<
typename Type>
161 static void Write(std::vector<char>& buffer,
Type val,
int pos=0,
int bytes=0)
163 if (bytes == 0) bytes =
sizeof(
Type);
164 for (
size_t i = 0; i < (size_t)bytes; ++i)
166 buffer[pos+i] = (
unsigned char)val;
171 template<
typename Type>
174 for (
size_t i = 0; i < (size_t)bytes; ++i)
Write(buffer, str[i], pos+i*
sizeof(
Type));
178 static void Read(
const char* buffer,
wchar_t& retVal,
int pos=0,
int bytes=0)
182 for (
int i=0; i<bytes; ++i)
184 retVal |= ((wchar_t)((
unsigned char)buffer[pos+i])) << 8*i;
188 static void ReadString(
const char* buffer,
wchar_t* str,
int pos=0,
int bytes=0)
193 static void Write(
char* buffer,
wchar_t val,
int pos=0,
int bytes=0)
196 for (
int i=0; i<bytes; ++i)
198 buffer[pos+i] = (
unsigned char)val;
203 static void WriteString(
char* buffer,
wchar_t* str,
int pos=0,
int bytes=0)
208 static void Read(
const std::vector<char>& buffer,
wchar_t& retVal,
int pos=0,
int bytes=0)
212 for (
int i=0; i<bytes; ++i)
214 retVal |= ((wchar_t)((
unsigned char)buffer[pos+i])) << 8*i;
218 static void ReadString(
const std::vector<char>& buffer,
wchar_t* str,
int pos=0,
int bytes=0)
223 static void Write(std::vector<char>& buffer,
wchar_t val,
int pos=0,
int bytes=0)
226 for (
int i=0; i<bytes; ++i)
228 buffer[pos+i] = (
unsigned char)val;
233 static void WriteString(std::vector<char>& buffer,
wchar_t* str,
int pos=0,
int bytes=0)
254 bool Create(
const wchar_t* filename);
255 bool Open(
const wchar_t* filename, std::ios_base::openmode mode=std::ios_base::in | std::ios_base::out);
265 int DelTree(
const wchar_t* path);
266 int DirectoryList(std::vector<std::vector<wchar_t> >& list,
const wchar_t* path=0);
271 int FileSize(
const wchar_t* path,
size_t& size);
272 int ReadFile(
const wchar_t* path,
char* data);
273 int ReadFile(
const wchar_t* path, std::vector<char>&data);
274 int WriteFile(
const wchar_t* path,
const char* data,
size_t size);
275 int WriteFile(
const wchar_t* path,
const std::vector<char>&data,
size_t size);
279 bool Create(
const char* filename);
280 bool Open(
const char* filename, std::ios_base::openmode mode=std::ios_base::in | std::ios_base::out);
289 int FileSize(
const char* path,
size_t& size);
290 int ReadFile(
const char* path,
char* data);
291 int ReadFile(
const char* path, std::vector<char>& data);
292 int WriteFile(
const char* path,
char* data,
size_t size);
293 int WriteFile(
const char* path, std::vector<char>& data,
size_t size);
300 void SplitPath(
const wchar_t* path,
wchar_t*& parentpath,
wchar_t*& propertyname);
311 void Write(
char* block);
312 void Read(
char* block);
347 size_t DataSize(
size_t startIndex,
bool isBig);
348 size_t ReadData(
size_t startIndex,
char* data,
bool isBig);
349 size_t WriteData(
const char* data,
size_t size,
int startIndex,
bool isBig);
350 void GetBlockIndices(
size_t startIndex, std::vector<size_t>& indices,
bool isBig);
353 void LinkBlocks(
size_t from,
size_t to,
bool isBig);
354 void FreeBlocks(std::vector<size_t>& indices,
bool isBig);
363 void Write(
char* block);
364 void Read(
char* block);
371 size_t maxLen1 = wcslen(lhs.
name_);
372 size_t maxLen2 = wcslen(rhs.
name_);
373 if (maxLen1 < maxLen2)
return true;
374 else if (maxLen1 > maxLen2)
return false;
378 if (result <= 0)
return true;
540 virtual size_t Read(
const char* data);
541 virtual size_t Write(
char* data);
554 virtual size_t Read(
const char* data);
555 virtual size_t Write(
char* data);
578 size_t Read(
const char* data);
579 size_t Write(
char* data);
597 size_t Read(
const char* data);
599 size_t Write(
char* data);
616 struct FileProtection;
621 struct WorkbookProtection;
625 virtual size_t Read(
const char* data);
626 virtual size_t Write(
char* data);
646 virtual size_t Read(
const char* data);
647 virtual size_t Write(
char* data);
665 virtual size_t Read(
const char* data);
666 virtual size_t Write(
char* data);
681 virtual size_t Read(
const char* data);
682 virtual size_t Write(
char* data);
695 virtual size_t Read(
const char* data);
696 virtual size_t Write(
char* data);
709 virtual size_t Read(
const char* data);
710 virtual size_t Write(
char* data);
720 virtual size_t Read(
const char* data);
721 virtual size_t Write(
char* data);
729 size_t Read(
const char* data);
730 size_t Write(
char* data);
755 virtual size_t Read(
const char* data);
756 virtual size_t Write(
char* data);
776 struct PrintGridlines;
779 struct DefaultRowHeight;
794 struct WorksheetProtection;
801 virtual size_t Read(
const char* data);
802 virtual size_t Write(
char* data);
816 virtual size_t Read(
const char* data);
817 virtual size_t Write(
char* data);
831 virtual size_t Read(
const char* data);
832 virtual size_t Write(
char* data);
840 virtual size_t Read(
const char* data);
841 virtual size_t Write(
char* data);
851 virtual size_t Read(
const char* data);
852 virtual size_t Write(
char* data);
861 virtual size_t Read(
const char* data);
862 virtual size_t Write(
char* data);
873 virtual size_t Read(
const char* data);
874 virtual size_t Write(
char* data);
880 void Read(
const char* data);
881 void Write(
char* data);
893 virtual size_t Read(
const char* data);
894 virtual size_t Write(
char* data);
910 virtual size_t Read(
const char* data);
911 virtual size_t Write(
char* data);
923 virtual size_t Read(
const char* data);
924 virtual size_t Write(
char* data);
938 virtual size_t Read(
const char* data);
939 virtual size_t Write(
char* data);
952 virtual size_t Read(
const char* data);
953 virtual size_t Write(
char* data);
966 virtual size_t Read(
const char* data);
967 virtual size_t Write(
char* data);
981 virtual size_t Read(
const char* data);
982 virtual size_t Write(
char* data);
989 virtual size_t Read(
const char* data);
990 virtual size_t Write(
char* data);
1012 size_t Read(
const char* data);
1013 size_t Write(
char* data);
1034 virtual size_t Read(
const char* data);
1035 virtual size_t Write(
char* data);
1042 size_t Read(
const char* data);
1043 size_t Write(
char* data);
1051 size_t Read(
const char* data);
1052 size_t Write(
char* data);
1061 virtual size_t Read(
const char* data);
1062 virtual size_t Write(
char* data);
1077 struct ConditionalFormattingTable;
1078 struct HyperlinkTable;
1080 struct SheetProtection;
1081 struct RangeProtection;
1083 size_t Read(
const char* data);
1084 size_t Write(
char* data);
1120 void New(
int sheets=3);
1121 bool Load(
const char* filename);
1123 bool SaveAs(
const char* filename);
1151 size_t Read(
const char* data,
size_t dataSize);
1152 size_t Write(
char* data);
1184 bool Rename(
const char* to);
1185 bool Rename(
const wchar_t* to);
1186 void Print(std::ostream& os,
char delimiter=
',',
char textQualifier=
'\0');
1203 std::vector<std::vector<BasicExcelCell> >
cells_;
1215 bool Get(
int& val)
const;
1216 bool Get(
double& val)
const;
1217 bool Get(
char* str)
const;
1218 bool Get(
wchar_t* str)
const;
1229 void Set(
double val);
1230 void Set(
const char* str);
1231 void Set(
const wchar_t* str);
void SetBlockSize(size_t size)
std::ios_base::openmode mode_
bool Swap(size_t index1, size_t index2)
size_t GetBlockSize() const
bool Move(size_t from, size_t to)
bool Write(size_t index, const char *block)
bool Insert(size_t index, const char *block)
bool Open(const wchar_t *filename, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
bool Read(size_t index, char *block)
bool Create(const wchar_t *filename)
std::vector< char > filename_
unsigned char propertyType_
friend bool operator==(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
friend bool operator>(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
friend bool operator!=(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
friend bool operator<(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
friend bool operator>=(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
friend bool operator<=(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
std::vector< PropertyTree * > children_
void IncreasePropertyReferences(PropertyTree *parentTree, size_t index)
bool Create(const wchar_t *filename)
int ReadFile(const wchar_t *path, char *data)
std::vector< int > sblocksIndices_
void DecreasePropertyReferences(PropertyTree *parentTree, size_t index)
void IncreaseLocationReferences(std::vector< size_t > indices)
void UpdateChildrenIndices(PropertyTree *parentTree)
void SplitPath(const wchar_t *path, wchar_t *&parentpath, wchar_t *&propertyname)
void DecreaseLocationReferences(std::vector< size_t > indices)
bool Open(const wchar_t *filename, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
PropertyTree * propertyTrees_
int WriteFile(const wchar_t *path, const char *data, size_t size)
size_t WriteData(const char *data, size_t size, int startIndex, bool isBig)
int MakeFile(const wchar_t *path)
int MakeProperty(const wchar_t *path, Property *property)
int RemoveFile(const wchar_t *path)
std::vector< PropertyTree * > previousDirectories_
std::vector< Property * > properties_
std::vector< char > block_
PropertyTree * currentDirectory_
int DirectoryList(std::vector< std::vector< wchar_t > > &list, const wchar_t *path=0)
void GetBlockIndices(size_t startIndex, std::vector< size_t > &indices, bool isBig)
void InsertPropertyTree(PropertyTree *parentTree, Property *property, size_t index)
int PresentWorkingDirectory(wchar_t *path)
int RemoveDirectory(const wchar_t *path)
size_t DataSize(size_t startIndex, bool isBig)
size_t GetFreeBlockIndex(bool isBig)
size_t ReadData(size_t startIndex, char *data, bool isBig)
int ChangeDirectory(const wchar_t *path)
PropertyTree * FindProperty(size_t index)
int FileSize(const wchar_t *path, size_t &size)
void DeletePropertyTree(PropertyTree *tree)
void FreeBlocks(std::vector< size_t > &indices, bool isBig)
int DelTree(const wchar_t *path)
void LinkBlocks(size_t from, size_t to, bool isBig)
std::vector< int > blocksIndices_
void ExpandBATArray(bool isBig)
bool Open(const char *filename, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
int MakeDirectory(const wchar_t *path)
double dval_
Double value stored in current Excel cell.
void SetDouble(double val)
Set content of current Excel cell to a double.
void Set(int val)
Set content of current Excel cell to an integer.
int Type() const
Get type of value stored in current Excel cell. Returns one of the above enums.
void SetInteger(int val)
Set content of current Excel cell to an integer.
bool Get(int &val) const
Get an integer value. Returns false if cell does not contain an integer or a double.
std::vector< wchar_t > wstr_
Unicode string stored in current Excel cell. Include null character.
size_t GetStringLength() const
Return length of ANSI or Unicode string (excluding null character).
friend std::ostream & operator<<(std::ostream &os, const BasicExcelCell &cell)
Print cell to output stream. Print a null character if cell is undefined.
std::vector< char > str_
ANSI string stored in current Excel cell. Include null character.
const char * GetString() const
Get an ANSI string. Returns 0 if cell does not contain an ANSI string.
int type_
Type of value stored in current Excel cell. Contains one of the above enums.
void EraseContents()
Erase the content of current Excel cell. Set type to UNDEFINED.
const wchar_t * GetWString() const
Get an Unicode string. Returns 0 if cell does not contain an Unicode string.
int ival_
Integer value stored in current Excel cell.
double GetDouble() const
Get a double value. Returns 0.0 if cell does not contain a double.
int GetInteger() const
Get an integer value. Returns 0 if cell does not contain an integer.
void SetString(const char *str)
Set content of current Excel cell to an ANSI string.
void SetWString(const wchar_t *str)
Set content of current Excel cell to an Unicode string.
wchar_t * GetUnicodeSheetName(size_t sheetIndex)
Get the worksheet name at the given index. Index starts from 0. Returns 0 if name is in Ansi format.
bool DeleteWorksheet(size_t sheetIndex)
Delete an Excel worksheet at the given index. Index starts from 0. Returns true if successful,...
void UpdateYExcelWorksheet()
Update yesheets_ using information from worksheets_.
void AdjustDBCellPositions()
void UpdateWorksheets()
Update worksheets_ using information from yesheets_.
std::vector< BasicExcelWorksheet > yesheets_
Parsed Worksheets.
void AdjustStreamPositions()
CompoundFile file_
Compound file handler.
void New(int sheets=3)
Create a new Excel workbook with a given number of spreadsheets (Minimum 1).
BasicExcelWorksheet * GetWorksheet(size_t sheetIndex)
Get a pointer to an Excel worksheet at the given index. Index starts from 0. Returns 0 if index is in...
size_t Read(const char *data, size_t dataSize)
std::vector< Worksheet > worksheets_
Raw Worksheets.
size_t GetTotalWorkSheets()
Total number of Excel worksheets in current Excel workbook.
void AdjustBoundSheetBOFPositions()
bool Load(const char *filename)
Load an Excel workbook from a file.
bool GetSheetName(size_t sheetIndex, char *name)
Get the worksheet name at the given index. Index starts from 0. Returns false if name is in Unicode f...
char * GetAnsiSheetName(size_t sheetIndex)
Get the worksheet name at the given index. Index starts from 0. Returns 0 if name is in Unicode forma...
BasicExcelWorksheet * AddWorksheet(int sheetIndex=-1)
Add a new Excel worksheet to the given index. Name given to worksheet is SheetX, where X is a number ...
bool SaveAs(const char *filename)
Save current Excel workbook to a file.
void AdjustExtSSTPositions()
bool Save()
Save current Excel workbook to opened file.
Workbook workbook_
Raw Workbook.
bool RenameWorksheet(size_t sheetIndex, const char *to)
Rename an Excel worksheet at the given index to the given ANSI name. Index starts from 0....
size_t sheetIndex_
Index of worksheet in workbook.
std::vector< std::vector< BasicExcelCell > > cells_
Cells matrix.
size_t GetTotalCols()
Total number of columns in current Excel worksheet.
BasicExcelCell * Cell(size_t row, size_t col)
Return a pointer to an Excel cell. row and col starts from 0. Returns 0 if row exceeds 65535 or col e...
size_t maxRows_
Total number of rows in worksheet.
char * GetAnsiSheetName()
Get the current worksheet name. Returns 0 if name is in Unicode format.
bool Rename(const char *to)
Rename current Excel worksheet to another ANSI name. Returns true if successful, false if otherwise.
bool EraseCell(size_t row, size_t col)
Erase content of a cell. row and col starts from 0. Returns true if successful, false if row or col e...
BasicExcelWorksheet(BasicExcel *excel, size_t sheetIndex)
wchar_t * GetUnicodeSheetName()
Get the current worksheet name. Returns 0 if name is in Ansi format.
void Print(std::ostream &os, char delimiter=',', char textQualifier='\0')
Print entire worksheet to an output stream, separating each column with the defined delimiter and enc...
bool GetSheetName(char *name)
Get the current worksheet name. Returns false if name is in Unicode format.
BasicExcel * excel_
Pointer to instance of BasicExcel.
size_t maxCols_
Total number of columns in worksheet.
size_t GetTotalRows()
Total number of rows in current Excel worksheet.
void UpdateCells()
Update cells using information from BasicExcel.worksheets_.
virtual size_t DataSize()
virtual size_t Write(char *data)
virtual size_t RecordSize()
std::vector< char > data_
virtual size_t Read(const char *data)
std::vector< size_t > continueIndices_
std::vector< BoundSheet > boundSheets_
std::vector< Style > styles_
size_t Read(const char *data)
std::vector< Font > fonts_
size_t Read(const char *data)
int GetRKValueFromDouble(double value)
Convert a double to a rk value.
int GetIntegerFromRKValue(int rkValue)
Convert a rk value to an integer.
double GetDoubleFromRKValue(int rkValue)
Convert a rk value to a double.
bool CanStoreAsRKValue(double value)
Returns true if the supplied double can be stored as a rk value.
bool IsRKValueADouble(int rkValue)
Returns true if the supplied rk value contains a double.
int GetRKValueFromInteger(int value)
Convert an integer to a rk value.
bool IsRKValueAnInteger(int rkValue)
Returns true if the supplied rk value contains an integer.
static void ReadString(const std::vector< char > &buffer, Type *str, int pos=0, int bytes=0)
static void WriteString(std::vector< char > &buffer, wchar_t *str, int pos=0, int bytes=0)
static void Read(const std::vector< char > &buffer, wchar_t &retVal, int pos=0, int bytes=0)
static void Read(const std::vector< char > &buffer, Type &retVal, int pos=0, int bytes=0)
static void ReadString(const char *buffer, Type *str, int pos=0, int bytes=0)
static void WriteString(std::vector< char > &buffer, Type *str, int pos=0, int bytes=0)
static void WriteString(char *buffer, Type *str, int pos=0, int bytes=0)
static void ReadString(const char *buffer, wchar_t *str, int pos=0, int bytes=0)
static void WriteString(char *buffer, wchar_t *str, int pos=0, int bytes=0)
static void Write(std::vector< char > &buffer, Type val, int pos=0, int bytes=0)
static void Read(const char *buffer, Type &retVal, int pos=0, int bytes=0)
static void Read(const char *buffer, wchar_t &retVal, int pos=0, int bytes=0)
static void Write(char *buffer, Type val, int pos=0, int bytes=0)
static void Write(char *buffer, wchar_t val, int pos=0, int bytes=0)
static void Write(std::vector< char > &buffer, wchar_t val, int pos=0, int bytes=0)
static void ReadString(const std::vector< char > &buffer, wchar_t *str, int pos=0, int bytes=0)
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
LargeString & operator=(const LargeString &s)
std::vector< wchar_t > wname_
size_t Read(const char *data)
std::vector< char > name_
size_t ContinueRead(const char *data, size_t size)
SmallString & operator=(const SmallString &s)
size_t Read(const char *data)
virtual size_t DataSize()
virtual size_t RecordSize()
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
virtual size_t DataSize()
virtual size_t RecordSize()
virtual size_t Write(char *data)
std::vector< int > streamPos_
std::vector< short > unused_
virtual size_t Read(const char *data)
std::vector< short > firstStringPos_
virtual size_t Read(const char *data)
virtual size_t RecordSize()
virtual size_t DataSize()
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
std::vector< LargeString > strings_
virtual size_t Write(char *data)
virtual size_t DataSize()
virtual size_t RecordSize()
virtual size_t DataSize()
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t RecordSize()
virtual size_t Read(const char *data)
short worksheetTabBarWidth_
virtual size_t Write(char *data)
short selectedWorksheetNo_
short activeWorksheetIndex_
short firstVisibleTabIndex_
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
std::vector< short > XFRecordIndices_
virtual size_t Read(const char *data)
virtual size_t RecordSize()
virtual size_t Write(char *data)
virtual size_t DataSize()
void Read(const char *data)
virtual size_t RecordSize()
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t DataSize()
std::vector< XFRK > XFRK_
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
union YExcel::Worksheet::CellTable::RowBlock::CellBlock::Number::@21 intdouble_
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t DataSize()
std::vector< short > offsets_
virtual size_t RecordSize()
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
short lastCellColIndexPlusOne_
virtual size_t Read(const char *data)
std::vector< CellBlock > cellBlocks_
size_t Read(const char *data)
std::vector< RowBlock > rowBlocks_
size_t Read(const char *data)
virtual size_t Write(char *data)
size_t lastUsedRowIndexPlusOne_
size_t firstUsedRowIndex_
short lastUsedColIndexPlusOne_
virtual size_t Read(const char *data)
virtual size_t Read(const char *data)
virtual size_t DataSize()
std::vector< size_t > DBCellPos_
size_t firstUnusedRowIndex_
virtual size_t Write(char *data)
virtual size_t RecordSize()
size_t firstUsedRowIndex_
short firstVisibleColIndex_
short magnificationFactorPageBreakPreview_
short firstVisibleRowIndex_
virtual size_t Read(const char *data)
short gridLineColourIndex_
virtual size_t Write(char *data)
short magnificationFactorNormalView_