| 13 | | {{{ |
| 14 | | #!cpp |
| 15 | | /////////////////////////////////////////////////////////////////////////////// |
| 16 | | Class ImportExport::@Excel |
| 17 | | |
| 18 | | /////////////////////////////////////////////////////////////////////////////// |
| 19 | | |
| 20 | | |
| 21 | | { |
| 22 | | |
| 23 | | /* //////////////////////////////////////////////////////////////////////////// |
| 24 | | Non static method defined at ImportExport::@Excel |
| 25 | | Call to methodSet ReadVMatrix(firstRow, col, _.maxRow-firstRow+1, 1) |
| 26 | | where col is the index of the column which first row has the specified name.Method GetSheetMaxRange must be called before. |
| 27 | | You must set minRow and minCol members before to calling GetSheetMaxRange if there are empty rows or columns before the data cells |
| 28 | | Returns a VMatrix with the numeric values of a rectangle of cells in the current work sheet. Non numeric or empty cells will be interpreted as unknown values. |
| 29 | | //////////////////////////////////////////////////////////////////////////// */ |
| 30 | | VMatrix GetFullVColumnByName(Text name, Real firstRow); |
| 31 | | |
| 32 | | /* //////////////////////////////////////////////////////////////////////////// |
| 33 | | Non static method defined at ImportExport::@Excel |
| 34 | | Reads from current active work sheet the content of specified cell returning one of these types: Text, Date, Real |
| 35 | | //////////////////////////////////////////////////////////////////////////// */ |
| 36 | | Anything ReadCell(Real row, Real col); |
| 37 | | |
| 38 | | /* //////////////////////////////////////////////////////////////////////////// |
| 39 | | Non static method defined at ImportExport::@Excel |
| 40 | | Returns a Set of Sets with the values of a rectangle of cells in the current work sheet. Each cell will have any of allowed types : Text, Real, Date. |
| 41 | | When argument columnDefaults is not the empty set, then if a cell hasn't the specified type for its column in argument columnDefaults, then the unknown value of the type will be returned. |
| 42 | | //////////////////////////////////////////////////////////////////////////// */ |
| 43 | | Set ReadRange(Real row_ini_, Real col_ini_, Real row_num, Real col_num, Set columnDefaults); |
| 44 | | |
| 45 | | /* //////////////////////////////////////////////////////////////////////////// |
| 46 | | Non static method defined at ImportExport::@Excel |
| 47 | | Call to methodSet ReadVMatrix(minRow=1, minCol=1, _.numRow, _.numCol) |
| 48 | | Method GetSheetMaxRange must be called before. |
| 49 | | You must set minRow and minCol members before to calling GetSheetMaxRange if there are empty rows or columns before the data cells |
| 50 | | Returns a VMatrix with the numeric values of a rectangle of cells in the current work sheet. Non numeric or empty cells will be interpreted as unknown values. |
| 51 | | //////////////////////////////////////////////////////////////////////////// */ |
| 52 | | Matrix GetFullVMatrix(Real void); |
| 53 | | |
| 54 | | /* //////////////////////////////////////////////////////////////////////////// |
| 55 | | Non static member defined at ImportExport::@Excel |
| 56 | | First column to be readed in method GetSheetMaxRange. Must be set by user if it's not the fiersdt one before to calling GetSheetMaxRange |
| 57 | | //////////////////////////////////////////////////////////////////////////// */ |
| 58 | | Real minCol = 1; |
| 59 | | |
| 60 | | /* //////////////////////////////////////////////////////////////////////////// |
| 61 | | Static member defined at ImportExport::@Excel |
| 62 | | Default date format. |
| 63 | | //////////////////////////////////////////////////////////////////////////// */ |
| 64 | | Text defaultDateFormat = "%Y-%m-%d"; |
| 65 | | |
| 66 | | /* //////////////////////////////////////////////////////////////////////////// |
| 67 | | Non static method defined at ImportExport::@Excel |
| 68 | | Activates the worksheet with specified name |
| 69 | | //////////////////////////////////////////////////////////////////////////// */ |
| 70 | | Real ActivateNamedWS(Text workSheetName, Real readRange, Real headerIndexedByName); |
| 71 | | |
| 72 | | /* //////////////////////////////////////////////////////////////////////////// |
| 73 | | Non static method defined at ImportExport::@Excel |
| 74 | | Writes a Matrix in the range of cells starting with the specified cell of current active work sheet. |
| 75 | | Returns the number of modified cells. |
| 76 | | //////////////////////////////////////////////////////////////////////////// */ |
| 77 | | Real WriteMatrix(Real row, Real col, Matrix values); |
| 78 | | |
| 79 | | /* //////////////////////////////////////////////////////////////////////////// |
| 80 | | Non static method defined at ImportExport::@Excel |
| 81 | | Returns a Matrix with the numeric values of a rectangle of cells in the current work sheet. Non numeric or empty cells will be interpreted as unknown values. |
| 82 | | //////////////////////////////////////////////////////////////////////////// */ |
| 83 | | Matrix ReadMatrix(Real row_ini, Real col_ini, Real row_num, Real col_num); |
| 84 | | |
| 85 | | /* //////////////////////////////////////////////////////////////////////////// |
| 86 | | Non static method defined at ImportExport::@Excel |
| 87 | | Saves changes in workbook in the specified path |
| 88 | | //////////////////////////////////////////////////////////////////////////// */ |
| 89 | | Real SaveAs(Text path); |
| 90 | | |
| 91 | | /* //////////////////////////////////////////////////////////////////////////// |
| 92 | | Non static method defined at ImportExport::@Excel |
| 93 | | Reads from current active work sheet the content of specified cell returning a Date |
| 94 | | //////////////////////////////////////////////////////////////////////////// */ |
| 95 | | Date ReadDate(Real row, Real col); |
| 96 | | |
| 97 | | /* //////////////////////////////////////////////////////////////////////////// |
| 98 | | Static method defined at ImportExport::@Excel |
| 99 | | Opens an existent workbook. |
| 100 | | //////////////////////////////////////////////////////////////////////////// */ |
| 101 | | @Excel Open(Text path); |
| 102 | | |
| 103 | | /* //////////////////////////////////////////////////////////////////////////// |
| 104 | | Non static method defined at ImportExport::@Excel |
| 105 | | Writes a range of cells starting with the specified cell of current active work sheet. Set cellValues must be a set of sets which elements are of one of these types: Text, Real, Date. |
| 106 | | Returns the number of modified cells. |
| 107 | | //////////////////////////////////////////////////////////////////////////// */ |
| 108 | | Real WriteRange(Real row0, Real col0, Set cellValues); |
| 109 | | |
| 110 | | /* //////////////////////////////////////////////////////////////////////////// |
| 111 | | Non static method defined at ImportExport::@Excel |
| 112 | | Call to methodSet GetRange(minRow=1, minCol=1, _.numRow, _.numCol, columnDefaults) |
| 113 | | Method GetSheetMaxRange must be called before. |
| 114 | | You must set minRow and minCol members before to calling GetSheetMaxRange if there are empty rows or columns before the data cells |
| 115 | | Returns a Set of Sets with the values of a rectangle of cells in the current work sheet. Each cell will have any of allowed types : Text, Real, Date. |
| 116 | | When argument columnDefaults is not the empty set, then if a cell hasn't the specified type for its column in argument columnDefaults, then the unknown value of the type will be returned. |
| 117 | | //////////////////////////////////////////////////////////////////////////// */ |
| 118 | | Set GetFullRange(Set columnDefaults); |
| 119 | | |
| 120 | | /* //////////////////////////////////////////////////////////////////////////// |
| 121 | | Static member defined at ImportExport::@Excel |
| 122 | | Controls warnings verbosity. |
| 123 | | //////////////////////////////////////////////////////////////////////////// */ |
| 124 | | Real showMassiveWarning = False; |
| 125 | | |
| 126 | | /* //////////////////////////////////////////////////////////////////////////// |
| 127 | | Non static method defined at ImportExport::@Excel |
| 128 | | Reads from current active work sheet the content of specified cell returning a Real |
| 129 | | //////////////////////////////////////////////////////////////////////////// */ |
| 130 | | Real ReadReal(Real row, Real col); |
| 131 | | |
| 132 | | /* //////////////////////////////////////////////////////////////////////////// |
| 133 | | Non static method defined at ImportExport::@Excel |
| 134 | | Writes a range of cells starting with the specified cell of current active work sheet. Set series must be a set of series with the same dating. |
| 135 | | Returns the number of modified cells. |
| 136 | | //////////////////////////////////////////////////////////////////////////// */ |
| 137 | | Real WriteSeries(Real row, Real col, Set series, Text dateFormat); |
| 138 | | |
| 139 | | /* //////////////////////////////////////////////////////////////////////////// |
| 140 | | Non static method defined at ImportExport::@Excel |
| 141 | | Returns a Set of series with specified dating. The first columne in the range is considered as the dates supporting the data of the Series. Every column from the column 2 on is considered as the data of one Serie. If dating is W then it will readed from the cell at left top corner. If this cell is empty or it's not a valid TimeSet then the default dating C will be used. |
| 142 | | //////////////////////////////////////////////////////////////////////////// */ |
| 143 | | Set ReadSeries(Real row_ini, Real col_ini, Real row_num, Real col_num, TimeSet dating, Text dateFormat); |
| 144 | | |
| 145 | | /* //////////////////////////////////////////////////////////////////////////// |
| 146 | | Non static method defined at ImportExport::@Excel |
| 147 | | Call to methodSet ReadMatrix(minRow=1, minCol=1, _.numRow, _.numCol) |
| 148 | | Method GetSheetMaxRange must be called before. |
| 149 | | You must set minRow and minCol members before to calling GetSheetMaxRange if there are empty rows or columns before the data cells |
| 150 | | Returns a Matrix with the numeric values of a rectangle of cells in the current work sheet. Non numeric or empty cells will be interpreted as unknown values. |
| 151 | | //////////////////////////////////////////////////////////////////////////// */ |
| 152 | | Matrix GetFullMatrix(Real void); |
| 153 | | |
| 154 | | /* //////////////////////////////////////////////////////////////////////////// |
| 155 | | Non static member defined at ImportExport::@Excel |
| 156 | | Last row that was readed in method GetSheetMaxRange. |
| 157 | | //////////////////////////////////////////////////////////////////////////// */ |
| 158 | | Real _.maxRow = ?; |
| 159 | | |
| 160 | | /* //////////////////////////////////////////////////////////////////////////// |
| 161 | | Non static member defined at ImportExport::@Excel |
| 162 | | The path of the workbook archive used in Open or New methods |
| 163 | | //////////////////////////////////////////////////////////////////////////// */ |
| 164 | | Text _.path; |
| 165 | | |
| 166 | | /* //////////////////////////////////////////////////////////////////////////// |
| 167 | | Non static member defined at ImportExport::@Excel |
| 168 | | Number of rows that were readed in method GetSheetMaxRange. |
| 169 | | //////////////////////////////////////////////////////////////////////////// */ |
| 170 | | Real _.numRow = ?; |
| 171 | | |
| 172 | | /* //////////////////////////////////////////////////////////////////////////// |
| 173 | | Non static method defined at ImportExport::@Excel |
| 174 | | Reads from current active work sheet the content of specified cell returning a Text |
| 175 | | //////////////////////////////////////////////////////////////////////////// */ |
| 176 | | Text ReadText(Real row, Real col); |
| 177 | | |
| 178 | | /* //////////////////////////////////////////////////////////////////////////// |
| 179 | | Static member defined at ImportExport::@Excel |
| 180 | | Maximum number of rows that a work sheet can store. Used in method GetSheetMaxRange. |
| 181 | | //////////////////////////////////////////////////////////////////////////// */ |
| 182 | | Real maxAllowedRow = 256^2; |
| 183 | | |
| 184 | | /* //////////////////////////////////////////////////////////////////////////// |
| 185 | | Non static method defined at ImportExport::@Excel |
| 186 | | Closes the workbook if it is has been open. If you doesn't close it, the workbook will be closed at instance destruction time. |
| 187 | | //////////////////////////////////////////////////////////////////////////// */ |
| 188 | | Real Close(Real void); |
| 189 | | |
| 190 | | /* //////////////////////////////////////////////////////////////////////////// |
| 191 | | Non static method defined at ImportExport::@Excel |
| 192 | | Scans the current work sheet in order to stablish a rectangle of interesting cells, starting from cell [minRow,minCol], wich default value is [1,1]. Reads along first column until an empty cell is found to stablish maxCol. Then, reads along first row until an empty cell is found to stablish maxRow. |
| 193 | | If argument headerIndexedByName is true stores the cells of first row in member _.headers and indexes it. |
| 194 | | Note that cells in first row cannot be repeated and must be of type Text. |
| 195 | | //////////////////////////////////////////////////////////////////////////// */ |
| 196 | | Real GetSheetMaxRange(Real headerIndexedByName); |
| 197 | | |
| 198 | | /* //////////////////////////////////////////////////////////////////////////// |
| 199 | | Non static member defined at ImportExport::@Excel |
| 200 | | If true, the first row was interpreted as column headers and will be stored in _.header. Used in method GetSheetMaxRange. |
| 201 | | //////////////////////////////////////////////////////////////////////////// */ |
| 202 | | Real _.headerIndexedByName = False; |
| 203 | | |
| 204 | | /* //////////////////////////////////////////////////////////////////////////// |
| 205 | | Non static method defined at ImportExport::@Excel |
| 206 | | Writes into the specified cell of current active work sheet the specified value with on of these types: Text, Date, Real |
| 207 | | //////////////////////////////////////////////////////////////////////////// */ |
| 208 | | Anything WriteCell(Real row, Real col, Anything value); |
| 209 | | |
| 210 | | /* //////////////////////////////////////////////////////////////////////////// |
| 211 | | Non static member defined at ImportExport::@Excel |
| 212 | | Column headers. Used in method GetSheetMaxRange when argument headerIndexedByName is true. |
| 213 | | //////////////////////////////////////////////////////////////////////////// */ |
| 214 | | Set _.header = Copy(Empty); |
| 215 | | |
| 216 | | /* //////////////////////////////////////////////////////////////////////////// |
| 217 | | Non static method defined at ImportExport::@Excel |
| 218 | | Returns de internal identifier of excel workbook handler. |
| 219 | | //////////////////////////////////////////////////////////////////////////// */ |
| 220 | | Real get_id(Real void); |
| 221 | | |
| 222 | | /* //////////////////////////////////////////////////////////////////////////// |
| 223 | | Non static method defined at ImportExport::@Excel |
| 224 | | Call to methodSet ReadSeries(minRow=1, minCol=1, _.numRow, _.numCol, dating) |
| 225 | | Method GetSheetMaxRange must be called before. |
| 226 | | You must set minRow and minCol members before to calling GetSheetMaxRange if there are empty rows or columns before the data cells |
| 227 | | Returns a Set of series with specified dating. The first columne in the range is considered as the dates supporting the data of the Series. Every column from the column 2 on is considered as the data of one Serie. If dating is W then it will readed from the cell at left top corner. If this cell is empty or it's not a valid TimeSet then the default dating C will be used. |
| 228 | | //////////////////////////////////////////////////////////////////////////// */ |
| 229 | | Set GetFullSeries(TimeSet dating, Text dateFormat); |
| 230 | | |
| 231 | | /* //////////////////////////////////////////////////////////////////////////// |
| 232 | | Non static method defined at ImportExport::@Excel |
| 233 | | Call to methodSet ReadVMatrix(firstRow, col, _.maxRow-firstRow+1, 1) |
| 234 | | Method GetSheetMaxRange must be called before. |
| 235 | | You must set minRow and minCol members before to calling GetSheetMaxRange if there are empty rows or columns before the data cells |
| 236 | | Returns a VMatrix with the numeric values of a rectangle of cells in the current work sheet. Non numeric or empty cells will be interpreted as unknown values. |
| 237 | | //////////////////////////////////////////////////////////////////////////// */ |
| 238 | | VMatrix GetFullVColumn(Real col, Real firstRow); |
| 239 | | |
| 240 | | /* //////////////////////////////////////////////////////////////////////////// |
| 241 | | Non static method defined at ImportExport::@Excel |
| 242 | | Writes a VMatrix in the range of cells starting with the specified cell of current active work sheet. |
| 243 | | Returns the number of modified cells. |
| 244 | | //////////////////////////////////////////////////////////////////////////// */ |
| 245 | | Real WriteVMatrix(Real row, Real col, Matrix values); |
| 246 | | |
| 247 | | /* //////////////////////////////////////////////////////////////////////////// |
| 248 | | Non static member defined at ImportExport::@Excel |
| 249 | | First row to be readed in method GetSheetMaxRange. Must be set by user if it's not the fiersdt one before to calling GetSheetMaxRange |
| 250 | | //////////////////////////////////////////////////////////////////////////// */ |
| 251 | | Real minRow = 1; |
| 252 | | |
| 253 | | /* //////////////////////////////////////////////////////////////////////////// |
| 254 | | Non static member defined at ImportExport::@Excel |
| 255 | | Last columns that was readed in method GetSheetMaxRange. |
| 256 | | //////////////////////////////////////////////////////////////////////////// */ |
| 257 | | Real _.maxCol = ?; |
| 258 | | |
| 259 | | /* //////////////////////////////////////////////////////////////////////////// |
| 260 | | Non static member defined at ImportExport::@Excel |
| 261 | | |
| 262 | | //////////////////////////////////////////////////////////////////////////// */ |
| 263 | | Real verbose = True; |
| 264 | | |
| 265 | | /* //////////////////////////////////////////////////////////////////////////// |
| 266 | | Non static member defined at ImportExport::@Excel |
| 267 | | Number of columns that were readed in method GetSheetMaxRange. |
| 268 | | //////////////////////////////////////////////////////////////////////////// */ |
| 269 | | Real _.numCol = ?; |
| 270 | | |
| 271 | | /* //////////////////////////////////////////////////////////////////////////// |
| 272 | | Non static method defined at ImportExport::@Excel |
| 273 | | Saves changes in workbook |
| 274 | | //////////////////////////////////////////////////////////////////////////// */ |
| 275 | | Real Save(Real void); |
| 276 | | |
| 277 | | /* //////////////////////////////////////////////////////////////////////////// |
| 278 | | Non static method defined at ImportExport::@Excel |
| 279 | | Call to methodSet ReadMatrix(firstRow, col, _.maxRow-firstRow+1, 1) |
| 280 | | Method GetSheetMaxRange must be called before. |
| 281 | | You must set minRow and minCol members before to calling GetSheetMaxRange if there are empty rows or columns before the data cells |
| 282 | | Returns a Matrix with the numeric values of a rectangle of cells in the current work sheet. Non numeric or empty cells will be interpreted as unknown values. |
| 283 | | //////////////////////////////////////////////////////////////////////////// */ |
| 284 | | Matrix GetFullColumn(Real col, Real firstRow); |
| 285 | | |
| 286 | | /* //////////////////////////////////////////////////////////////////////////// |
| 287 | | Static member defined at ImportExport::@Excel |
| 288 | | Maximum number of columns that a work sheet can store. Used in method GetSheetMaxRange. |
| 289 | | //////////////////////////////////////////////////////////////////////////// */ |
| 290 | | Real maxAllowedCol = 256; |
| 291 | | |
| 292 | | /* //////////////////////////////////////////////////////////////////////////// |
| 293 | | Non static method defined at ImportExport::@Excel |
| 294 | | Activates the n-th worksheet. |
| 295 | | If readRange is true then calls to GetSheetMaxRange with argument headerIndexedByName |
| 296 | | //////////////////////////////////////////////////////////////////////////// */ |
| 297 | | Real ActivateWS(Real workSheetNumber, Real readRange, Real headerIndexedByName); |
| 298 | | |
| 299 | | /* //////////////////////////////////////////////////////////////////////////// |
| 300 | | Non static method defined at ImportExport::@Excel |
| 301 | | Returns true if the specified cell is empty |
| 302 | | //////////////////////////////////////////////////////////////////////////// */ |
| 303 | | Real IsEmptyCell(Real row, Real col); |
| 304 | | |
| 305 | | /* //////////////////////////////////////////////////////////////////////////// |
| 306 | | Non static method defined at ImportExport::@Excel |
| 307 | | Returns a VMatrix with the numeric values of a rectangle of cells in the current work sheet. Non numeric or empty cells will be interpreted as unknown values. |
| 308 | | //////////////////////////////////////////////////////////////////////////// */ |
| 309 | | VMatrix ReadVMatrix(Real row_ini, Real col_ini, Real row_num, Real col_num); |
| 310 | | |
| 311 | | /* //////////////////////////////////////////////////////////////////////////// |
| 312 | | Non static method defined at ImportExport::@Excel |
| 313 | | Call to methodSet ReadMatrix(firstRow, col, _.maxRow-firstRow+1, 1) |
| 314 | | where col is the index of the column which first row has the specified name.Method GetSheetMaxRange must be called before. |
| 315 | | You must set minRow and minCol members before to calling GetSheetMaxRange if there are empty rows or columns before the data cells |
| 316 | | Returns a Matrix with the numeric values of a rectangle of cells in the current work sheet. Non numeric or empty cells will be interpreted as unknown values. |
| 317 | | //////////////////////////////////////////////////////////////////////////// */ |
| 318 | | Matrix GetFullColumnByName(Text name, Real firstRow); |
| 319 | | |
| 320 | | /* //////////////////////////////////////////////////////////////////////////// |
| 321 | | Static method defined at ImportExport::@Excel |
| 322 | | Creates an empty workbook. |
| 323 | | //////////////////////////////////////////////////////////////////////////// */ |
| 324 | | @Excel New(Text path) |
| 325 | | }; |
| 326 | | }}} |