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