NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
BasicExcel.hpp
Go to the documentation of this file.
1// Created by Yap Chun Wei
2// Version 1.0 (20 April 2006)
3// Version 1.1 (22 April 2006)
4 // - Fixed bugs with compound files not being able to write files more than 65535 bytes.
5 // - Fixed bugs with reading and writing to Excel files containing many strings.
6// Version 1.2 (30 April 2006)
7 // - Added operator<< to pass BasicExcelCell to an output stream.
8 // - Added Print() to BasicExcelWorksheet to print the worksheet to an output stream.
9 // - Change BasicExcelCell Get functions to const functions.
10 // - Rename BasicExcelWorksheet functions RenameWorkSheet() to Rename().
11// Version 1.3 (10 May 2006)
12 // - Fixed bugs with reading from Excel files containing Asian characters.
13// Version 1.4 (13 May 2006)
14 // - Fixed bugs with reading and writing to Excel files containing many strings.
15// Version 1.5 (15 May 2006)
16 // - Remove code for ExtSST because it was causing problems with reading and writing to Excel files containing many strings.
17// Version 1.6 (16 May 2006)
18 // - Optimized code for reading and writing.
19// Version 1.7 (22 May 2006)
20 // - Fixed code to remove some warnings.
21 // - Fixed bug with BasicExcelWorksheet::Cell.
22 // - Fixed bug with BasicExcel::UpdateWorksheets().
23// Version 1.8 (23 May 2006)
24 // - Fixed bug with reading Excel files containing many unicode strings.
25 // - Fixed code to remove some warnings.
26 // - Fixed variable code_ duplication in BoolErr.
27 // - Minor changes to BasicExcelCell:Set functions.
28// Version 1.9 (24 May 2006)
29 // - Changed name_ in Style from SmallString to LargeString.
30 // - Fixed bug in BasicExcelCell::GetString and BasicExcelCell::GetWString.
31 // - Minor changes to functions in BasicExcel and BasicExcelWorksheet which checks for unicode.
32 // - Minor change to SmallString::Read.
33// Version 1.10 (30 May 2006)
34 // - Fixed bug with reading Excel files containing many strings.
35 // - Remove memory leaks.
36// Version 1.11 (2 June 2006)
37 // - Fixed bug with reading and writing Excel files containing many unicode and ANSI strings.
38// Version 1.12 (6 June 2006)
39 // - Fixed bug with reading and writing Excel files containing many unicode and ANSI strings.
40// Version 1.13 (1 August 2006)
41 // - Changed BasicExcelCell::Get() so that it will get a stored double as an integer or vice versa if necessary.
42 // - Changed BasicExcelCell::Get() so that it will not cause any errors if a string is empty.
43 // - Changed BasicExcelCell::SetString() and BasicExcelCell::SetWString() so that it will not save an empty string.
44// Version 1.14 (6 August 2006)
45 // - Fixed bug with reading Excel files that contain a null string.
46
47#ifndef BASICEXCEL_HPP
48#define BASICEXCEL_HPP
49
50#include <algorithm>
51#include <cmath>
52#include <functional>
53#include <iostream>
54#include <iomanip>
55#include <fstream>
56#include <map>
57#include <vector>
58#include <cstring>
59
60#define UTF16
61#ifdef UTF16
62 #define SIZEOFWCHAR_T 2
63#else
64 #define SIZEOFWCHAR_T sizeof(wchar_t)
65#endif
66
67namespace YCompoundFiles
68{
69class Block
70// PURPOSE: In charge of handling blocks of data from a file
71{
72public:
73 Block();
74
75// File handling functions
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);
78 bool Close();
79 bool IsOpen();
80
81// Block handling functions
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);
89
90// Misc functions
91 size_t GetBlockSize() const {return blockSize_;}
92 void SetBlockSize(size_t size)
93 {
94 blockSize_ = size;
96 }
97
98protected:
99 std::vector<char> filename_;
100 std::ios_base::openmode mode_;
101 std::fstream file_;
103 size_t indexEnd_;
104 size_t fileSize_;
105};
106
108{
109 template<typename Type>
110 static void Read(const char* buffer, Type& retVal, int pos=0, int bytes=0)
111 {
112 retVal = Type(0);
113 if (bytes == 0) bytes = sizeof(Type);
114 for (size_t i=0; i < (size_t)bytes; ++i)
115 {
116 retVal |= ((Type)((unsigned char)buffer[pos+i])) << 8*i;
117 }
118 }
119
120 template<typename Type>
121 static void ReadString(const char* buffer, Type* str, int pos=0, int bytes=0)
122 {
123 for (size_t i = 0; i < (size_t)bytes; ++i) Read(buffer, str[i], pos+i*sizeof(Type));
124 }
125
126 template<typename Type>
127 static void Write(char* buffer, Type val, int pos=0, int bytes=0)
128 {
129 if (bytes == 0) bytes = sizeof(Type);
130 for (size_t i = 0; i < (size_t)bytes; ++i)
131 {
132 buffer[pos+i] = (unsigned char)val;
133 val >>= 8;
134 }
135 }
136
137 template<typename Type>
138 static void WriteString(char* buffer, Type* str, int pos=0, int bytes=0)
139 {
140 for (size_t i = 0; i < (size_t)bytes; ++i) Write(buffer, str[i], pos+i*sizeof(Type));
141 }
142
143 template<typename Type>
144 static void Read(const std::vector<char>& buffer, Type& retVal, int pos=0, int bytes=0)
145 {
146 retVal = Type(0);
147 if (bytes == 0) bytes = sizeof(Type);
148 for (size_t i = 0; i < (size_t)bytes; ++i)
149 {
150 retVal |= ((Type)((unsigned char)buffer[pos+i])) << 8*i;
151 }
152 }
153
154 template<typename Type>
155 static void ReadString(const std::vector<char>& buffer, Type* str, int pos=0, int bytes=0)
156 {
157 for (size_t i = 0; i < (size_t)bytes; ++i) Read(buffer, str[i], pos+i*sizeof(Type));
158 }
159
160 template<typename Type>
161 static void Write(std::vector<char>& buffer, Type val, int pos=0, int bytes=0)
162 {
163 if (bytes == 0) bytes = sizeof(Type);
164 for (size_t i = 0; i < (size_t)bytes; ++i)
165 {
166 buffer[pos+i] = (unsigned char)val;
167 val >>= 8;
168 }
169 }
170
171 template<typename Type>
172 static void WriteString(std::vector<char>& buffer, Type* str, int pos=0, int bytes=0)
173 {
174 for (size_t i = 0; i < (size_t)bytes; ++i) Write(buffer, str[i], pos+i*sizeof(Type));
175 }
176
177
178 static void Read(const char* buffer, wchar_t& retVal, int pos=0, int bytes=0)
179 {
180 retVal = wchar_t(0);
181 if (bytes == 0) bytes = SIZEOFWCHAR_T;
182 for (int i=0; i<bytes; ++i)
183 {
184 retVal |= ((wchar_t)((unsigned char)buffer[pos+i])) << 8*i;
185 }
186 }
187
188 static void ReadString(const char* buffer, wchar_t* str, int pos=0, int bytes=0)
189 {
190 for (int i=0; i<bytes; ++i) Read(buffer, str[i], pos+i*SIZEOFWCHAR_T);
191 }
192
193 static void Write(char* buffer, wchar_t val, int pos=0, int bytes=0)
194 {
195 if (bytes == 0) bytes = SIZEOFWCHAR_T;
196 for (int i=0; i<bytes; ++i)
197 {
198 buffer[pos+i] = (unsigned char)val;
199 val >>= 8;
200 }
201 }
202
203 static void WriteString(char* buffer, wchar_t* str, int pos=0, int bytes=0)
204 {
205 for (int i=0; i<bytes; ++i) Write(buffer, str[i], pos+i*SIZEOFWCHAR_T);
206 }
207
208 static void Read(const std::vector<char>& buffer, wchar_t& retVal, int pos=0, int bytes=0)
209 {
210 retVal = wchar_t(0);
211 if (bytes == 0) bytes = SIZEOFWCHAR_T;
212 for (int i=0; i<bytes; ++i)
213 {
214 retVal |= ((wchar_t)((unsigned char)buffer[pos+i])) << 8*i;
215 }
216 }
217
218 static void ReadString(const std::vector<char>& buffer, wchar_t* str, int pos=0, int bytes=0)
219 {
220 for (int i=0; i<bytes; ++i) Read(buffer, str[i], pos+i*SIZEOFWCHAR_T);
221 }
222
223 static void Write(std::vector<char>& buffer, wchar_t val, int pos=0, int bytes=0)
224 {
225 if (bytes == 0) bytes = SIZEOFWCHAR_T;
226 for (int i=0; i<bytes; ++i)
227 {
228 buffer[pos+i] = (unsigned char)val;
229 val >>= 8;
230 }
231 }
232
233 static void WriteString(std::vector<char>& buffer, wchar_t* str, int pos=0, int bytes=0)
234 {
235 for (int i=0; i<bytes; ++i) Write(buffer, str[i], pos+i*SIZEOFWCHAR_T);
236 }
237};
238
240{
241public:
247
248 CompoundFile();
250
251// User accessible functions
252public:
253 // Compound File functions
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);
256 bool Close();
257 bool IsOpen();
258
259 // Directory functions
260 int ChangeDirectory(const wchar_t* path);
261 int MakeDirectory(const wchar_t* path);
262 int PresentWorkingDirectory(wchar_t* path);
263 int PresentWorkingDirectory(std::vector<wchar_t>& path);
264 int RemoveDirectory(const wchar_t* path);
265 int DelTree(const wchar_t* path);
266 int DirectoryList(std::vector<std::vector<wchar_t> >& list, const wchar_t* path=0);
267
268 // File functions
269 int MakeFile(const wchar_t* path);
270 int RemoveFile(const wchar_t* path);
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);
276
277
278 // ANSI char functions
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);
281 int ChangeDirectory(const char* path);
282 int MakeDirectory(const char* path);
283 int PresentWorkingDirectory(char* path);
284 int PresentWorkingDirectory(std::vector<char>& path);
285 int RemoveDirectory(const char* path);
286 int DelTree(const char* path);
287 int MakeFile(const char* path);
288 int RemoveFile(const char* path);
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);
294
295// Protected functions and data members
296protected:
297 // General functions and data members
298 void IncreaseLocationReferences(std::vector<size_t> indices);
299 void DecreaseLocationReferences(std::vector<size_t> indices);
300 void SplitPath(const wchar_t* path, wchar_t*& parentpath, wchar_t*& propertyname);
301 std::vector<char> block_;
303
304 // Header related functions and data members
305 bool LoadHeader();
306 void SaveHeader();
307 class Header
308 {
309 public:
310 Header();
311 void Write(char* block);
312 void Read(char* block);
313
314 long long fileType_; // Magic number identifying this as a compound file system (0x0000)
315 int uk1_; // Unknown constant (0x0008)
316 int uk2_; // Unknown constant (0x000C)
317 int uk3_; // Unknown constant (0x0010)
318 int uk4_; // Unknown constant (0x0014)
319 short uk5_; // Unknown constant (revision?) (0x0018)
320 short uk6_; // Unknown constant (version?) (0x001A)
321 short uk7_; // Unknown constant (0x001C)
322 short log2BigBlockSize_; // Log, base 2, of the big block size (0x001E)
323 int log2SmallBlockSize_; // Log, base 2, of the small block size (0x0020)
324 int uk8_; // Unknown constant (0x0024)
325 int uk9_; // Unknown constant (0x0028)
326 int BATCount_; // Number of elements in the BAT array (0x002C)
327 int propertiesStart_; // Block index of the first block of the property table (0x0030)
328 int uk10_; // Unknown constant (0x0034)
329 int uk11_; // Unknown constant (0x0038)
330 int SBATStart_; // Block index of first big block containing the small block allocation table (SBAT) (0x003C)
331 int SBATCount_; // Number of big blocks holding the SBAT (0x0040)
332 int XBATStart_; // Block index of the first block in the Extended Block Allocation Table (XBAT) (0x0044)
333 int XBATCount_; // Number of elements in the Extended Block Allocation Table (to be added to the BAT) (0x0048)
334 int BATArray_[109]; // Array of block indices constituting the Block Allocation Table (BAT) (0x004C, 0x0050, 0x0054 ... 0x01FC)
335
338
339 private:
340 void Initialize();
341 };
343
344 // BAT related functions and data members
345 void LoadBAT();
346 void SaveBAT();
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);
351 size_t GetFreeBlockIndex(bool isBig);
352 void ExpandBATArray(bool isBig);
353 void LinkBlocks(size_t from, size_t to, bool isBig);
354 void FreeBlocks(std::vector<size_t>& indices, bool isBig);
355 std::vector<int> blocksIndices_;
356 std::vector<int> sblocksIndices_;
357
358 // Properties related functions and data members
360 {
361 public:
362 Property();
363 void Write(char* block);
364 void Read(char* block);
365 friend bool operator==(const CompoundFile::Property& lhs, const CompoundFile::Property& rhs)
366 {
367 return (!wcscmp(lhs.name_, rhs.name_));
368 }
369 friend bool operator< (const CompoundFile::Property& lhs, const CompoundFile::Property& rhs)
370 {
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;
375 else
376 {
377 int result = wcscmp(lhs.name_, rhs.name_);
378 if (result <= 0) return true;
379 else return false;
380 }
381 }
382 friend bool operator!=(const CompoundFile::Property& lhs, const CompoundFile::Property& rhs) {return !(lhs == rhs);}
383 friend bool operator> (const CompoundFile::Property& lhs, const CompoundFile::Property& rhs) {return (rhs < lhs);}
384 friend bool operator<=(const CompoundFile::Property& lhs, const CompoundFile::Property& rhs) {return !(rhs < lhs);}
385 friend bool operator>=(const CompoundFile::Property& lhs, const CompoundFile::Property& rhs) {return !(lhs < rhs);}
386
387 wchar_t name_[32]; // A unicode null-terminated uncompressed 16bit string (lblocke the high bytes) containing the name of the property. (0x00, 0x02, 0x04, ... 0x3E)
388 short nameSize_; // Number of characters in the NAME field (0x40)
389 unsigned char propertyType_; // Property type (directory, file, or root) Byte 1 (directory), 2 (file), or 5 (root entry) (0x42)
390 unsigned char nodeColor_; // Node color (0x43)
391 int previousProp_; // Previous property index (0x44)
392 int nextProp_; // Next property index (0x48)
393 int childProp_; // First child property index (0x4c)
394 int uk1_;
395 int uk2_;
396 int uk3_;
397 int uk4_;
398 int uk5_;
399 int seconds1_; // Seconds component of the created timestamp? (0x64)
400 int days1_; // Days component of the created timestamp? (0x68)
401 int seconds2_; // Seconds component of the modified timestamp? (0x6C)
402 int days2_; // Days component of the modified timestamp? (0x70)
403 int startBlock_; // Starting block of the file, used as the first block in the file and the pointer to the next block from the BAT (0x74)
404 int size_; // Actual size of the file this property points to. (used to truncate the blocks to the real size). (0x78)
405 };
407 {
408 public:
409 PropertyTree();
413 size_t index_;
414 std::vector<PropertyTree*> children_;
415 };
416 void LoadProperties();
417 void SaveProperties();
418 int MakeProperty(const wchar_t* path, Property* property);
419 PropertyTree* FindProperty(size_t index);
420 PropertyTree* FindProperty(const wchar_t* path);
421 PropertyTree* FindProperty(PropertyTree* parentTree, wchar_t* name);
422 void InsertPropertyTree(PropertyTree* parentTree, Property* property, size_t index);
424 void UpdateChildrenIndices(PropertyTree* parentTree);
425 void IncreasePropertyReferences(PropertyTree* parentTree, size_t index);
426 void DecreasePropertyReferences(PropertyTree* parentTree, size_t index);
429 std::vector<Property*> properties_;
430 std::vector<PropertyTree*> previousDirectories_;
431};
432} // YCompoundFiles namespace end
433
434namespace YExcel
435{
436using namespace YCompoundFiles;
437
438struct CODE
439{
440 enum { FORMULA=0x0006, //Token array and the result of a formula cell.
441 YEOF=0x000A, //End of a record block with leading BOF record.
442 CALCCOUNT=0x000C, //Maximum number of times the forumlas should be iteratively calculated
443 CALCMODE=0x000D, //Calculate formulas manually, automatically, or automatically except for multiple table operations
444 PRECISION=0x000E, //Whether formulas use the real cell values for calculation or the values displayed on the screen.
445 REFMODE=0x000F, //Method used to show cell addresses in formulas.
446 DELTA=0x0010, //Maximum change of the result to exit an iteration.
447 ITERATION=0x0011, //Whether iterations are allowed while calculating recursive formulas.
448 PROTECT=0x0012, //Whether worksheet or a workbook is protected against modification.
449 PASSWORD=0x0013, //16-bit hash value, calculated from the worksheet or workbook protection password.
450 HEADER=0x0014, //Page header string for the current worksheet.
451 FOOTER=0x0015, //Page footer string for the current worksheet.
452 EXTERNSHEET=0x0017, //List with indexes to SUPBOOK records
453 NAME=0x0018, //Name and token array of an internal defined name.
454 WINDOWPROTECT=0x0019, //Whether the window configuration of the document is protected.
455 SELECTION=0x001D, //Addresses of all selected cell ranges and position of the active cell for a pane in the current sheet.
456 DATEMODE=0x0022, //Base date for displaying date values.
457 EXTERNNAME=0x0023, //Name of an external defined name, name of an add-in function, a DDE item or an OLE object storage identifier.
458 LEFTMARGIN=0x0026, //Left page margin of the current worksheet.
459 RIGHTMARGIN=0x0027, //Right page margin of the current worksheet.
460 TOPMARGIN=0x0028, //Top page margin of the current worksheet.
461 BOTTOMMARGIN=0x0029, //Bottom page margin of current worksheet
462 PRINTHEADERS=0x002A, //Whether row and column headers (the areas with row numbers and column letters) will be printed.
463 PRINTGRIDLINES=0x002B, //Whether sheet grid lines will be printed.
464 FILEPASS=0x002F, //Information about the read/write password of the file.
465 FONT=0x0031, //Information about a used font, including character formatting.
466 TABLE=0x0036, //Information about a multiple operation table in the sheet.
467 CONTINUE=0x003C, //Continue from previous record
468 WINDOW1=0x003D, //General settings for the workbook global settings.
469 BACKUP=0x0040, //Make backup of file while saving?
470 PANE=0x0041, //Position of window panes.
471 CODEPAGE=0x0042, //Text encoding used to encode byte strings
472 DCONREF=0x0051,
473 DEFCOLWIDTH=0x0055, //Default column width for columns that do not have a specific width set
474 XCT=0x0059, //Number of immediately following CRN records.
475 CRN=0x005A, //Contents of an external cell or cell range.
476 FILESHARING=0x005B, //Information about write protection, for instance the write protection password.
477 WRITEACCESS=0x005C, //Name of the user that has saved the file.
478 UNCALCED=0x005E, //Formulas have not been recalculated before the document was saved.
479 SAVERECALC=0x005F, //"Recalculate before save" option
480 OBJECTPROTECT=0x0063, //Whether objects of the current sheet are protected.
481 COLINFO=0x007D, //Width for a given range of columns
482 GUTS=0x0080, //Layout of outline symbols.
483 WSBOOL=0x0081, //16-bit value with boolean options for the current sheet.
484 GRIDSET=0x0082, //Whether option to print sheet grid lines has ever been changed.
485 HCENTER=0x0083, //Sheet is centred horizontally when printed.
486 VCENTER=0x0084, //Whether sheet is centred vertically when printed.
487 BOUNDSHEET=0x0085, //Sheet inside of the workbook
488 WRITEPROT=0x0086, //Whether file is write protected.
489 COUNTRY=0x008C, //User interface language of the Excel version that has saved the file, system regional settings at the time the file was saved.
490 HIDEOBJ=0x008D, //Whether and how to show objects in the workbook.
491 SORT=0x0090, //Last settings from the "Sort" dialogue for each sheet.
492 PALETTE=0x0092, //Definition of all user-defined colours available for cell and object formatting.
493 SETUP=0x00A1, //Page format settings of the current sheet.
494 SHRFMLA=0x00BC, //Token array of a shared formula.
495 MULRK=0x00BD, //Cell range containing RK value cells. All cells are located in the same row.
496 MULBLANK=0x00BE, //Cell range of empty cells. All cells are located in the same row.
497 DBCELL=0x00D7, //Relative offsets to calculate stream position of the first cell record for each row.
498 BOOKBOOL=0x00DA, //Save values linked from external workbooks records and XCT records?
499 SCENPROTECT=0x00DD, //Whether scenarios of the current sheet are protected.
500 XF=0x00E0, //Formatting information for cells, rows, columns or styles.
501 MERGEDCELLS=0x00E5, //All merged cell ranges of the current sheet.
502 SST=0x00FC, //List of all strings used anywhere in the workbook.
503 LABELSST=0x00FD, //Cell that contains a string.
504 EXTSST=0x00FF, //Create a hash table with stream offsets to the SST record to optimise string search operations.
505 LABELRANGES=0x015F, //Addresses of all row and column label ranges in the current sheet.
506 USESELFS=0x0160, //Whether formulas in the workbook can use "natural language formulas".
507 DSF=0x0161, //Whether file contains an addition BIFF5/BIFF7 workbook stream.
508 SUPBOOK=0x01AE, //URL of an external document and a list of sheet names inside this document.
509 CONDFMT=0x01B0, //List of cell range addresses for all cells with equal conditional formatting.
510 CF=0x01B1, //Condition and the formatting attributes applied to the cells specified in the CONDFMT record, if the condition is met
511 DVAL=0x01B2, //List header of the data validity table in the current sheet.
512 HLINK=0x01B8, //One cell address or a cell range where all cells contain the same hyperlink.
513 DV=0x01BE, //Data validity settings and a list of cell ranges which contain these settings.
514 DIMENSIONS=0x0200, //Range address of the used area in the current sheet.
515 BLANK=0x0201, //Empty cell, contains cell address and formatting information
516 NUMBER=0x0203, //Cell that contains a floating-point value.
517 BOOLERR=0x0205, //Error value cell
518 STRING=0x0207, //Result of a string formula.
519 ROW=0x0208, //Properties of a single row in the sheet.
520 INDEX=0x020B, //Range of used rows and stream positions of several records of the current sheet.
521 ARRAY=0x0221, //Token array of an array formula
522 WINDOW2=0x023E, //Additional settings for the window of a specific worksheet.
523 RK=0x027E, //Cell that contains an RK value (encoded integer or floating point value).
524 STYLE=0x0293, //Name of a user-defined cell style or specific options for a built-in cell style.
525 FORMAT=0x041E, //Number format.
526 SHRFMLA1=0x04BC, //Token array of a shared formula (added).
527 QUICKTIP=0x0800, //Cell range and text for a tool tip.
528 BOF=0x0809, //Beginning of file
529 SHEETLAYOUT=0x0862, //Colour of the tab below the sheet containing the sheet name.
530 SHEETPROTECTION=0x0867, //Additional options for sheet protection.
531 RANGEPROTECTION=0x0868 //Information about special protected ranges in a protected sheet.
532 };
533};
534
536{
537public:
538 Record();
539 virtual ~Record();
540 virtual size_t Read(const char* data);
541 virtual size_t Write(char* data);
542 virtual size_t DataSize();
543 virtual size_t RecordSize();
544 short code_;
545 std::vector<char> data_;
546 size_t dataSize_;
548 std::vector<size_t> continueIndices_;
549};
550
551struct BOF : public Record
552{
553 BOF();
554 virtual size_t Read(const char* data);
555 virtual size_t Write(char* data);
556 short version_;
557 short type_;
562};
563
564struct YEOF : public Record
565{
566 YEOF();
567};
568
570{
571 SmallString();
572 ~SmallString();
573 SmallString(const SmallString& s);
575 const SmallString& operator=(const char* str);
576 const SmallString& operator=(const wchar_t* str);
577 void Reset();
578 size_t Read(const char* data);
579 size_t Write(char* data);
580 size_t DataSize();
581 size_t RecordSize();
582 size_t StringSize();
583 wchar_t* wname_;
584 char* name_;
586};
587
589{
590 LargeString();
591 ~LargeString();
592 LargeString(const LargeString& s);
594 const LargeString& operator=(const char* str);
595 const LargeString& operator=(const wchar_t* str);
596 void Reset();
597 size_t Read(const char* data);
598 size_t ContinueRead(const char* data, size_t size);
599 size_t Write(char* data);
600 size_t DataSize();
601 size_t RecordSize();
602 size_t StringSize();
603 std::vector<wchar_t> wname_;
604 std::vector<char> name_;
608};
609
611{
612public:
613 Workbook();
614
615public:
616 struct FileProtection;
617 struct CodePage;
618 struct DSF;
619 struct TabID;
620 struct FnGroupCount;
621 struct WorkbookProtection;
622 struct Window1 : public Record
623 {
624 Window1();
625 virtual size_t Read(const char* data);
626 virtual size_t Write(char* data);
629 short width_;
630 short height_;
631 short options_;
636 };
637 struct Backup;
638 struct HideObj;
639 struct DateMode;
640 struct Precision;
641 struct RefreshAll;
642 struct BookBool;
643 struct Font : public Record
644 {
645 Font();
646 virtual size_t Read(const char* data);
647 virtual size_t Write(char* data);
648 virtual size_t DataSize();
649 virtual size_t RecordSize();
650 short height_;
651 short options_;
653 short weight_;
660 };
661 struct Format;
662 struct XF : public Record
663 {
664 XF();
665 virtual size_t Read(const char* data);
666 virtual size_t Write(char* data);
676 short colour2_;
677 };
678 struct Style : public Record
679 {
680 Style();
681 virtual size_t Read(const char* data);
682 virtual size_t Write(char* data);
683 virtual size_t DataSize();
684 virtual size_t RecordSize();
687 char level_;
689 };
690 struct Palette;
691 struct UseSelfs;
692 struct BoundSheet : public Record
693 {
694 BoundSheet();
695 virtual size_t Read(const char* data);
696 virtual size_t Write(char* data);
697 virtual size_t DataSize();
698 virtual size_t RecordSize();
701 char type_;
703 };
704 struct Country;
705 struct LinkTable;
706 struct SharedStringTable : public Record
707 {
709 virtual size_t Read(const char* data);
710 virtual size_t Write(char* data);
711 virtual size_t DataSize();
712 virtual size_t RecordSize();
715 std::vector<LargeString> strings_;
716 };
717 struct ExtSST : public Record
718 {
719 ExtSST();
720 virtual size_t Read(const char* data);
721 virtual size_t Write(char* data);
722 virtual size_t DataSize();
723 virtual size_t RecordSize();
725 std::vector<int> streamPos_;
726 std::vector<short> firstStringPos_;
727 std::vector<short> unused_;
728 };
729 size_t Read(const char* data);
730 size_t Write(char* data);
731 size_t DataSize();
732 size_t RecordSize();
733
736 std::vector<Font> fonts_;
737 std::vector<XF> XFs_;
738 std::vector<Style> styles_;
739 std::vector<BoundSheet> boundSheets_;
743};
744
746{
747public:
748 Worksheet();
749
750public:
751 struct Uncalced;
752 struct Index : public Record
753 {
754 Index();
755 virtual size_t Read(const char* data);
756 virtual size_t Write(char* data);
757 virtual size_t DataSize();
758 virtual size_t RecordSize();
763 std::vector<size_t> DBCellPos_;
764
765 };
767 {
768 struct CalcCount;
769 struct CalcMode;
770 struct RefMode;
771 struct Delta;
772 struct Iteration;
773 struct SafeRecalc;
774 };
775 struct PrintHeaders;
776 struct PrintGridlines;
777 struct Gridset;
778 struct Guts;
779 struct DefaultRowHeight;
780 struct WSBool;
782 {
783 struct Header;
784 struct Footer;
785 struct HCenter;
786 struct VCenter;
787 struct LeftMargin;
788 struct RightMargin;
789 struct TopMargin;
790 struct BottomMargin;
791 struct PLS;
792 struct Setup;
793 };
794 struct WorksheetProtection;
795 struct DefColWidth;
796 struct ColInfo;
797 struct Sort;
798 struct Dimensions : public Record
799 {
800 Dimensions();
801 virtual size_t Read(const char* data);
802 virtual size_t Write(char* data);
807 short unused_;
808 };
810 {
811 struct RowBlock
812 {
813 struct Row : public Record
814 {
815 Row();
816 virtual size_t Read(const char* data);
817 virtual size_t Write(char* data);
821 short height_;
822 short unused1_;
823 short unused2_;
825 };
827 {
828 struct Blank : public Record
829 {
830 Blank();
831 virtual size_t Read(const char* data);
832 virtual size_t Write(char* data);
836 };
837 struct BoolErr : public Record
838 {
839 BoolErr();
840 virtual size_t Read(const char* data);
841 virtual size_t Write(char* data);
845 char value_;
846 char error_;
847 };
848 struct LabelSST : public Record
849 {
850 LabelSST();
851 virtual size_t Read(const char* data);
852 virtual size_t Write(char* data);
857 };
858 struct MulBlank : public Record
859 {
860 MulBlank();
861 virtual size_t Read(const char* data);
862 virtual size_t Write(char* data);
863 virtual size_t DataSize();
864 virtual size_t RecordSize();
867 std::vector<short> XFRecordIndices_;
869 };
870 struct MulRK : public Record
871 {
872 MulRK();
873 virtual size_t Read(const char* data);
874 virtual size_t Write(char* data);
875 virtual size_t DataSize();
876 virtual size_t RecordSize();
877 struct XFRK
878 {
879 XFRK();
880 void Read(const char* data);
881 void Write(char* data);
884 };
887 std::vector<XFRK> XFRK_;
889 };
890 struct Number : public Record
891 {
892 Number();
893 virtual size_t Read(const char* data);
894 virtual size_t Write(char* data);
898 double value_;
899
900 private:
901 union
902 {
903 long long intvalue_;
906 };
907 struct RK : public Record
908 {
909 RK();
910 virtual size_t Read(const char* data);
911 virtual size_t Write(char* data);
916 };
917
918 struct Formula : public Record
919 {
920 struct Array : public Record
921 {
922 Array();
923 virtual size_t Read(const char* data);
924 virtual size_t Write(char* data);
925 virtual size_t DataSize();
926 virtual size_t RecordSize();
931 short options_;
933 std::vector<char> formula_;
934 };
935 struct ShrFmla : public Record
936 {
937 ShrFmla();
938 virtual size_t Read(const char* data);
939 virtual size_t Write(char* data);
940 virtual size_t DataSize();
941 virtual size_t RecordSize();
946 short unused_;
947 std::vector<char> formula_;
948 };
949 struct ShrFmla1 : public Record
950 {
951 ShrFmla1();
952 virtual size_t Read(const char* data);
953 virtual size_t Write(char* data);
954 virtual size_t DataSize();
955 virtual size_t RecordSize();
960 short unused_;
961 std::vector<char> formula_;
962 };
963 struct Table : public Record
964 {
965 Table();
966 virtual size_t Read(const char* data);
967 virtual size_t Write(char* data);
972 short options_;
977 };
978 struct String : public Record
979 {
980 String();
981 virtual size_t Read(const char* data);
982 virtual size_t Write(char* data);
983 virtual size_t DataSize();
984 virtual size_t RecordSize();
985 std::vector<wchar_t> string_;
986 };
987
988 Formula();
989 virtual size_t Read(const char* data);
990 virtual size_t Write(char* data);
991 virtual size_t DataSize();
992 virtual size_t RecordSize();
996 char result_[8];
997 short options_;
999 std::vector<char> RPNtoken_;
1000 short type_;
1001
1007 };
1008
1009 CellBlock();
1010 ~CellBlock();
1011 void Reset();
1012 size_t Read(const char* data);
1013 size_t Write(char* data);
1014 size_t DataSize();
1015 size_t RecordSize();
1016 short RowIndex();
1017 short ColIndex();
1019 short type_;
1021
1030 };
1031 struct DBCell : public Record
1032 {
1033 DBCell();
1034 virtual size_t Read(const char* data);
1035 virtual size_t Write(char* data);
1036 virtual size_t DataSize();
1037 virtual size_t RecordSize();
1039 std::vector<short> offsets_;
1040 };
1041
1042 size_t Read(const char* data);
1043 size_t Write(char* data);
1044 size_t DataSize();
1045 size_t RecordSize();
1046
1047 std::vector<Row> rows_;
1048 std::vector<CellBlock> cellBlocks_;
1050 };
1051 size_t Read(const char* data);
1052 size_t Write(char* data);
1053 size_t DataSize();
1054 size_t RecordSize();
1055
1056 std::vector<RowBlock> rowBlocks_;
1057 };
1058 struct Window2 : public Record
1059 {
1060 Window2();
1061 virtual size_t Read(const char* data);
1062 virtual size_t Write(char* data);
1071 };
1072 struct SCL;
1073 struct Pane;
1074 struct Selection;
1075 struct MergedCells;
1076 struct LabelRanges;
1077 struct ConditionalFormattingTable;
1078 struct HyperlinkTable;
1079 struct SheetLayout;
1080 struct SheetProtection;
1081 struct RangeProtection;
1082
1083 size_t Read(const char* data);
1084 size_t Write(char* data);
1085 size_t DataSize();
1086 size_t RecordSize();
1087
1094};
1095
1096bool IsRKValueAnInteger(int rkValue);
1097bool IsRKValueADouble(int rkValue);
1098double GetDoubleFromRKValue(int rkValue);
1099int GetIntegerFromRKValue(int rkValue);
1100int GetRKValueFromDouble(double value);
1101int GetRKValueFromInteger(int value);
1102bool CanStoreAsRKValue(double value);
1103
1104// Forward declarations
1105class BasicExcel;
1107class BasicExcelCell;
1108
1109/*******************************************************************************************************/
1110/* Actual classes to read and write to Excel files */
1111/*******************************************************************************************************/
1113{
1114public:
1115 BasicExcel();
1116 BasicExcel(const char* filename);
1117 ~BasicExcel();
1118
1119public: // File functions.
1120 void New(int sheets=3);
1121 bool Load(const char* filename);
1122 bool Save();
1123 bool SaveAs(const char* filename);
1124
1125public: // Worksheet functions.
1126 size_t GetTotalWorkSheets();
1127
1128 BasicExcelWorksheet* GetWorksheet(size_t sheetIndex);
1129 BasicExcelWorksheet* GetWorksheet(const char* name);
1130 BasicExcelWorksheet* GetWorksheet(const wchar_t* name);
1131
1132 BasicExcelWorksheet* AddWorksheet(int sheetIndex=-1);
1133 BasicExcelWorksheet* AddWorksheet(const char* name, int sheetIndex=-1);
1134 BasicExcelWorksheet* AddWorksheet(const wchar_t* name, int sheetIndex=-1);
1135
1136 bool DeleteWorksheet(size_t sheetIndex);
1137 bool DeleteWorksheet(const char* name);
1138 bool DeleteWorksheet(const wchar_t* name);
1139
1140 char* GetAnsiSheetName(size_t sheetIndex);
1141 wchar_t* GetUnicodeSheetName(size_t sheetIndex);
1142 bool GetSheetName(size_t sheetIndex, char* name);
1143 bool GetSheetName(size_t sheetIndex, wchar_t* name);
1144
1145 bool RenameWorksheet(size_t sheetIndex, const char* to);
1146 bool RenameWorksheet(size_t sheetIndex, const wchar_t* to);
1147 bool RenameWorksheet(const char* from, const char* to);
1148 bool RenameWorksheet(const wchar_t* from, const wchar_t* to);
1149
1150private: // Functions to read and write raw Excel format.
1151 size_t Read(const char* data, size_t dataSize);
1152 size_t Write(char* data);
1153 void AdjustStreamPositions();
1155 void AdjustDBCellPositions();
1156 void AdjustExtSSTPositions();
1157
1159 WORKSHEET=0x0010, CHART=0x0020};
1160
1161private: // Internal functions
1162 void UpdateYExcelWorksheet();
1163 void UpdateWorksheets();
1164
1165public:
1168 std::vector<Worksheet> worksheets_;
1169 std::vector<BasicExcelWorksheet> yesheets_;
1170};
1171
1173{
1174 friend class BasicExcel;
1175
1176public:
1177 BasicExcelWorksheet(BasicExcel* excel, size_t sheetIndex);
1178
1179public: // Worksheet functions
1180 char* GetAnsiSheetName();
1181 wchar_t* GetUnicodeSheetName();
1182 bool GetSheetName(char* name);
1183 bool GetSheetName(wchar_t* name);
1184 bool Rename(const char* to);
1185 bool Rename(const wchar_t* to);
1186 void Print(std::ostream& os, char delimiter=',', char textQualifier='\0');
1187
1188public: // Cell functions
1189 size_t GetTotalRows();
1190 size_t GetTotalCols();
1191
1192 BasicExcelCell* Cell(size_t row, size_t col);
1193 bool EraseCell(size_t row, size_t col);
1194
1195private: // Internal functions
1196 void UpdateCells();
1197
1198private:
1201 size_t maxRows_;
1202 size_t maxCols_;
1203 std::vector<std::vector<BasicExcelCell> > cells_;
1204};
1205
1207{
1208public:
1210
1211public:
1213 int Type() const;
1214
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;
1219 size_t GetStringLength() const;
1220
1221 int GetInteger() const;
1222 double GetDouble() const;
1223 const char* GetString() const;
1224 const wchar_t* GetWString() const;
1225
1226 friend std::ostream& operator<<(std::ostream& os, const BasicExcelCell& cell);
1227
1228 void Set(int val);
1229 void Set(double val);
1230 void Set(const char* str);
1231 void Set(const wchar_t* str);
1232
1233 void SetInteger(int val);
1234 void SetDouble(double val);
1235 void SetString(const char* str);
1236 void SetWString(const wchar_t* str);
1237
1238 void EraseContents();
1239
1240private:
1241 int type_;
1242 int ival_;
1243 double dval_;
1244 std::vector<char> str_;
1245 std::vector<wchar_t> wstr_;
1246};
1247
1248} // Namespace end
1249#endif
#define SIZEOFWCHAR_T
Definition: BasicExcel.hpp:62
void SetBlockSize(size_t size)
Definition: BasicExcel.hpp:92
std::ios_base::openmode mode_
Definition: BasicExcel.hpp:100
bool Swap(size_t index1, size_t index2)
Definition: BasicExcel.cpp:123
size_t GetBlockSize() const
Definition: BasicExcel.hpp:91
bool Move(size_t from, size_t to)
Definition: BasicExcel.cpp:149
bool Write(size_t index, const char *block)
Definition: BasicExcel.cpp:104
bool Insert(size_t index, const char *block)
Definition: BasicExcel.cpp:176
bool Open(const wchar_t *filename, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
Definition: BasicExcel.cpp:33
bool Read(size_t index, char *block)
Definition: BasicExcel.cpp:89
bool Create(const wchar_t *filename)
Definition: BasicExcel.cpp:12
bool Erase(size_t index)
Definition: BasicExcel.cpp:198
std::vector< char > filename_
Definition: BasicExcel.hpp:99
friend bool operator==(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
Definition: BasicExcel.hpp:365
friend bool operator>(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
Definition: BasicExcel.hpp:383
friend bool operator!=(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
Definition: BasicExcel.hpp:382
friend bool operator<(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
Definition: BasicExcel.hpp:369
friend bool operator>=(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
Definition: BasicExcel.hpp:385
friend bool operator<=(const CompoundFile::Property &lhs, const CompoundFile::Property &rhs)
Definition: BasicExcel.hpp:384
std::vector< PropertyTree * > children_
Definition: BasicExcel.hpp:414
void IncreasePropertyReferences(PropertyTree *parentTree, size_t index)
bool Create(const wchar_t *filename)
Definition: BasicExcel.cpp:431
int ReadFile(const wchar_t *path, char *data)
Definition: BasicExcel.cpp:794
std::vector< int > sblocksIndices_
Definition: BasicExcel.hpp:356
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)
int WriteFile(const wchar_t *path, const char *data, size_t size)
Definition: BasicExcel.cpp:848
size_t WriteData(const char *data, size_t size, int startIndex, bool isBig)
int MakeFile(const wchar_t *path)
Definition: BasicExcel.cpp:740
int MakeProperty(const wchar_t *path, Property *property)
int RemoveFile(const wchar_t *path)
Definition: BasicExcel.cpp:757
std::vector< PropertyTree * > previousDirectories_
Definition: BasicExcel.hpp:430
std::vector< Property * > properties_
Definition: BasicExcel.hpp:429
std::vector< char > block_
Definition: BasicExcel.hpp:301
PropertyTree * currentDirectory_
Definition: BasicExcel.hpp:428
int DirectoryList(std::vector< std::vector< wchar_t > > &list, const wchar_t *path=0)
Definition: BasicExcel.cpp:717
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)
Definition: BasicExcel.cpp:608
int RemoveDirectory(const wchar_t *path)
Definition: BasicExcel.cpp:657
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)
Definition: BasicExcel.cpp:523
PropertyTree * FindProperty(size_t index)
int FileSize(const wchar_t *path, size_t &size)
Definition: BasicExcel.cpp:772
void DeletePropertyTree(PropertyTree *tree)
void FreeBlocks(std::vector< size_t > &indices, bool isBig)
int DelTree(const wchar_t *path)
Definition: BasicExcel.cpp:671
void LinkBlocks(size_t from, size_t to, bool isBig)
std::vector< int > blocksIndices_
Definition: BasicExcel.hpp:355
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)
Definition: BasicExcel.cpp:591
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()
size_t Write(char *data)
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 ~Record()
virtual size_t DataSize()
virtual size_t Write(char *data)
size_t recordSize_
Definition: BasicExcel.hpp:547
virtual size_t RecordSize()
std::vector< char > data_
Definition: BasicExcel.hpp:545
virtual size_t Read(const char *data)
std::vector< size_t > continueIndices_
Definition: BasicExcel.hpp:548
SharedStringTable sst_
Definition: BasicExcel.hpp:740
size_t Write(char *data)
std::vector< BoundSheet > boundSheets_
Definition: BasicExcel.hpp:739
std::vector< XF > XFs_
Definition: BasicExcel.hpp:737
std::vector< Style > styles_
Definition: BasicExcel.hpp:738
size_t Read(const char *data)
std::vector< Font > fonts_
Definition: BasicExcel.hpp:736
size_t Read(const char *data)
size_t Write(char *data)
CellTable cellTable_
Dimensions dimensions_
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.
char name[32]
Definition: resampler.cpp:371
static void ReadString(const std::vector< char > &buffer, Type *str, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:155
static void WriteString(std::vector< char > &buffer, wchar_t *str, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:233
static void Read(const std::vector< char > &buffer, wchar_t &retVal, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:208
static void Read(const std::vector< char > &buffer, Type &retVal, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:144
static void ReadString(const char *buffer, Type *str, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:121
static void WriteString(std::vector< char > &buffer, Type *str, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:172
static void WriteString(char *buffer, Type *str, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:138
static void ReadString(const char *buffer, wchar_t *str, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:188
static void WriteString(char *buffer, wchar_t *str, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:203
static void Write(std::vector< char > &buffer, Type val, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:161
static void Read(const char *buffer, Type &retVal, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:110
static void Read(const char *buffer, wchar_t &retVal, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:178
static void Write(char *buffer, Type val, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:127
static void Write(char *buffer, wchar_t val, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:193
static void Write(std::vector< char > &buffer, wchar_t val, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:223
static void ReadString(const std::vector< char > &buffer, wchar_t *str, int pos=0, int bytes=0)
Definition: BasicExcel.hpp:218
int fileHistoryFlags_
Definition: BasicExcel.hpp:560
virtual size_t Read(const char *data)
short buildYear_
Definition: BasicExcel.hpp:559
int lowestExcelVersion_
Definition: BasicExcel.hpp:561
short buildIdentifier_
Definition: BasicExcel.hpp:558
short version_
Definition: BasicExcel.hpp:556
virtual size_t Write(char *data)
LargeString & operator=(const LargeString &s)
std::vector< wchar_t > wname_
Definition: BasicExcel.hpp:603
size_t Read(const char *data)
size_t Write(char *data)
std::vector< char > name_
Definition: BasicExcel.hpp:604
size_t ContinueRead(const char *data, size_t size)
SmallString & operator=(const SmallString &s)
size_t Read(const char *data)
size_t Write(char *data)
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_
Definition: BasicExcel.hpp:725
std::vector< short > unused_
Definition: BasicExcel.hpp:727
virtual size_t Read(const char *data)
std::vector< short > firstStringPos_
Definition: BasicExcel.hpp:726
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_
Definition: BasicExcel.hpp:715
virtual size_t Write(char *data)
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)
virtual size_t Write(char *data)
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 Read(const char *data)
virtual size_t Read(const char *data)
std::vector< CellBlock > cellBlocks_
std::vector< RowBlock > rowBlocks_
size_t Write(char *data)
size_t Read(const 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 DataSize()
std::vector< size_t > DBCellPos_
Definition: BasicExcel.hpp:763
virtual size_t Write(char *data)
virtual size_t RecordSize()
virtual size_t Read(const char *data)
virtual size_t Write(char *data)