How it extracts CSV data from a sheet
ConvertExcelToCSVProcessor extracts CSV data with following rules:
- Find the fist cell which has a value in it (the FirstCell).
- Scan cells in the first row, starting from the FirstCell,
until it reaches to a cell after which no cell with a value can not be found in the row (the FirstRowLastCell).
- Process the 2nd row and later, from the column of FirstCell to the column of FirstRowLastCell.
- If a row does not have any cell that has a value, then the row is ignored.
As an example, the sheet shown below will be:
row | A | B | C | D | E | F | G |
1 | | | | | | | |
2 | | | x | y | z | | |
3 | | | 1 | | | | |
4 | 2 | | | 3 | | | |
5 | | | | | 4 | | |
6 | | | 5 | 6 | 7 | | |
7 | | | | | | 8 | |
8 | | | | | | | |
9 | | | | | 9 | | |
10 | | | | | | | |
11 | | | | | | | |
converted to following CSV:
x,y,z
1,,
,3,
,,4
5,6,7
,,9
- C2(x) is the FirstCell, and E2(z) is the FirstRowLastCell.
- A4(2) is ignored because it is out of range. So is F7(8).
- Row 7 and 8 are ignored because those do not have a valid cell.
- It is important to have a header row as shown in the example to define data area,
especially when a sheet includes empty cells.