## 4.2.15.16.4.11  XLSX
The XCO XLSX module offers a set of standard abstractions and APIs to programmatically work with XLSX workbooks and their worksheets (e.g. coming form an uploaded Microsoft Excel .XLSX file).
The XCO XLSX module exposes three external APIs:
- XCO\_CP\_XLSX: Access to general abstractions used throughout the XCO XLSX module
- XCO\_CP\_XLSX\_SELECTION: Access to selection pattern builders used to build selection patterns
- XCO\_CP\_XLSX\_READ\_ACCESS: Access to abstractions used when reading the content of an XLSX worksheet
## Document handles
The starting point for any programmatic interaction with an XLSX workbook and its worksheets is obtaining a handle for the containing document via XCO\_CP\_XLSX=&gt;DOCUMENT. As of now, document handles can be obtained for the complete file content of an .XLSX file, which must be provided as an XSTRING:
```
 Sample Code DATA lv_file_content TYPE xstring. " LV_FILE_CONTENT must be populated with the complete file content of the .XLSX file " whose content shall be processed programmatically. DATA(lo_document) = xco_cp_xlsx=>document->for_file_content( lv_file_content ).
```
The obtained document handle then allows to obtain a read access, which is the starting point for accessing the cell contents of the worksheets contained in the document XLSX Read Access [page 1711].
## Coordinates
Within the XCO XLSX module, a worksheet is regarded as a space with two dimensions, with the first dimension being the column and the second dimension being the row. Consequently, a cell in a worksheet is uniquely determined by providing values for its column and row. A coordinate (an object of type CL\_XCO\_XLSX\_COORDINATE) uniquely fixes a value for a given dimension, for example, for a value for a column or row. In office suites, e.g. Microsoft Excel, alphabetic values are used to identify columns and numeric values are used to identify rows. The XCO XLSX module provides support for both variants so that alphabetic as well as numeric values can be used freely when values are provided for columns and rows.
- Alphabetic coordinates: A, B, C, … Z, AA, AB, ...ZZ, AAA, AAB, ...
- Numeric coordinates: 1, 2, 3, ...
Coordinates can be obtained via XCO\_CP\_XLSX=&gt;COORDINATE for both alphabetic and numeric values and once obtained, both the alphabetic as well as the numeric value can be retrieved for a coordinate. This also provides an easy way to translate between alphabetic and numeric coordinate values, for example:
##  Sample Code
DATA(lo\_coordinate\_1) = xco\_cp\_xlsx=&gt;coordinate-&gt;for\_alphabetic\_value( 'AA' ).
- " LV\_COORD\_1\_NUMERIC\_VALUE will be an integer with value 27. DATA(lv\_coord\_1\_numeric\_value) = lo\_coordinate\_1-&gt;get\_numeric\_value( ).
- " LV\_COORD\_1\_ALPHABETIC\_VALUE will be a string with value AA. DATA(lv\_coord\_1\_alphabetic\_value) = lo\_coordinate\_1-&gt;get\_alphabetic\_value( ).
DATA(lo\_coordinate\_2) = xco\_cp\_xlsx=&gt;coordinate-&gt;for\_numeric\_value( 27 ).
- " LV\_COORD\_2\_NUMERIC\_VALUE will be an integer with value 27. DATA(lv\_coord\_2\_numeric\_value) = lo\_coordinate\_2-&gt;get\_numeric\_value( ).
- " LV\_COORD\_2\_ALPHABETIC\_VALUE will be a string with value AA. DATA(lv\_coord\_2\_alphabetic\_value) = lo\_coordinate\_2-&gt;get\_alphabetic\_value( ).
It's possible to derive new coordinates from existing coordinates such as objects of type
CL\_XCO\_XLSX\_COORDINATE, by using the SHIFT method to either increment or decrement the value of the coordinate (depending on the sign of the provided offset).
## Selection patterns
Selections are a central concept within the XCO XLSX module. A selection is based on a selection pattern which encapsulates a prescription according to which individual cells are identified in a given worksheet which then form the selection. To illustrate the concepts and offered selection patterns consider the following exemplary portion of an XLSX worksheet:
|   A | B   | C   | D   | E   | F   | ...   |
|-----|-----|-----|-----|-----|-----|-------|
|   1 |     |     |     |     |     |       |
|   2 | 1   | 2   | 3   | 4   |     |       |
|     | A   | B   | C   | D E   | ...   |
|-----|-----|-----|-----|-------|-------|
| 3   | 5   | 6   | 7   | 8     |       |
| 4   | 9   | 10  | 11  | 12    |       |
| 5   | 13  | 14  | 15  | 16    |       |
| 6   |     |     |     |       |       |
| ... |     |     |     |       |       |
For the purposes of the following code samples, it's assumed that except for the cell values shown above, all other cells of the worksheet are initial. Supported selection patterns can be built via selection pattern builders which are obtainable via XCO\_CP\_XLSX\_SELECTION=&gt;PATTERN\_BUILDER.
## Simple from-to selection patterns
A simple from-to selection pattern allows to define static boundary values for columns and rows. It's not required to specify a boundary value for each dimension, hence both bounded and unbounded selections are possible. Consider the following characteristic examples:
## 
- Sample Code " The selection pattern LO\_PATTERN\_1 will be a bounded rectangle, matching values " 6, 7, 10 and 11 of the above worksheet. DATA(lo\_pattern\_1) = xco\_cp\_xlsx\_selection=&gt;pattern\_builder-&gt;simple\_from\_to( )-&gt;from\_column( xco\_cp\_xlsx=&gt;coordinate-&gt;for\_alphabetic\_value( 'C' ) )-&gt;to\_column( xco\_cp\_xlsx=&gt;coordinate-&gt;for\_alphabetic\_value( 'D' ) )-&gt;from\_row( xco\_cp\_xlsx=&gt;coordinate-&gt;for\_numeric\_value( 3 ) )-&gt;to\_row( xco\_cp\_xlsx=&gt;coordinate-&gt;for\_numeric\_value( 4 ) )-&gt;get\_pattern( ). " The selection pattern LO\_PATTERN\_2 will be unbounded at the bottom, matching " values 6, 7, 10, 11, 14 and 15 of the above worksheet. DATA(lo\_pattern\_2) = xco\_cp\_xlsx\_selection=&gt;pattern\_builder-&gt;simple\_from\_to( )-&gt;from\_column( xco\_cp\_xlsx=&gt;coordinate-&gt;for\_alphabetic\_value( 'C' ) )-&gt;to\_column( xco\_cp\_xlsx=&gt;coordinate-&gt;for\_alphabetic\_value( 'D' ) )-&gt;from\_row( xco\_cp\_xlsx=&gt;coordinate-&gt;for\_numeric\_value( 3 ) )-&gt;get\_pattern( ). " The selection pattern LO\_PATTERN\_3 will be unbounded at the bottom and at the " right, matching values 6, 7, 8, 10, 11, 12, 14, 15 and 16 of the above worksheet. DATA(lo\_pattern\_3) = xco\_cp\_xlsx\_selection=&gt;pattern\_builder-&gt;simple\_from\_to( )-&gt;from\_column( xco\_cp\_xlsx=&gt;coordinate-&gt;for\_alphabetic\_value( 'C' ) )-&gt;from\_row( xco\_cp\_xlsx=&gt;coordinate-&gt;for\_numeric\_value( 3 ) )-&gt;get\_pattern( ). " The selection pattern LO\_PATTERN\_4 is completely unbounded, matching all cells of the " worksheet, hence also all values of the above worksheet. DATA(lo\_pattern\_4) = xco\_cp\_xlsx\_selection=&gt;pattern\_builder-&gt;simple\_from\_to( )-&gt;get\_pattern( ).