10 | | * https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html |
| 10 | |
| 11 | * https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html |
| 12 | |
| 13 | == Implementation == |
| 14 | |
| 15 | === Interactive Importer === |
| 16 | |
| 17 | Besides .csv files, the interactive importer now also accepts .xls/.xlsx (Excel) files. |
| 18 | |
| 19 | If such a file is uploaded, the importer will search for a sheet with the name "SahanaData" (or fall back to the first sheet, of "SahanaData" is not present), and import it under the same formatting rules as the corresponding CSV format. |
| 20 | |
| 21 | The sheet is read from the top left, and the first row interpreted as column names. Else, the sheet is parsed, transformed and imported just like the corresponding CSV format. |
| 22 | |
| 23 | The XLS workbook can contain other, more user-friendly sheets with online help, tooltips andor/ validation, and have the "SahanaData" sheet hidden and populated by macros. |
| 24 | |
| 25 | === xls2tree === |
| 26 | |
| 27 | Xls2tree is the back-end method to parse Excel sheets. |
| 28 | |
| 29 | Note: unlike originally planned, this is not a pre-processor to convert XLS into CSV and then pass into the CSV importer, but just like csv2tree (the CSV parser) it converts the Excel sheet into an ElementTree for import. However, this ElementTree is transformed with the same XSLT stylesheets as the CSV format. |
| 30 | |
| 31 | The xls2tree method is much more flexible than the current importer front-end suggests - it can read any sheet in the workbook and a range of rows/columns anywhere on the sheet (i.e. not only top left). It also accepts a column mapping as parameter which allows to specify which column corresponds to which field instead of reading the column headers from the sheet. |
| 32 | |
| 33 | This flexibility could be utilized to implement a front-end that allows the user to import from any XLS document even if there is no "SahanaData" sheet in CSV format. These "XLS format configurations" (sheet name, cell range, column mapping) could be saved ("Saved XLS Formats"), and then re-used for other documents - which allows to quickly adapt to various document sources. |
| 34 | |
| 35 | Xls2tree can also work from open work books, which can be used to implement an XLS bulk importer to import multiple resources and/or multiple sheets from the same XLS work book in one go. |