I am receiving an xlsx-File from another application. It contains a header line with filters set starting in row 3, followed by the actual data from row 4 onwards, like this:
When reading it with workbook read range, it is not able to correctly read the headers, neither with option ‘addHeaders’ set nor without. It does not matter from which row on I read the data, the resulting datatable always looks like this, with generic header names like column1, column2 …:
Only when I manually remove the filters from the excel file and copy data+header to a new blank workbook, read range is able to correctly read it to a datatable.
Excel read range does it correctly out of the box, but excel is not installed on the system the robot is designated to run. To me it looks like a bug. Any idea on how to solve this, i.e. read the correct values from row 3 instead of generic header names?
You’re right there is a table, I found it. I tried your approach with get table range, it points to the same range that I read previously, but the result is still wrong:
I wanted to prepare the excel-file so I could share it here, but as soon as I replace the content cells with anonymized data and save the file, read range reads it correctly the next time.
Unfortunately not. The file is generated per robot run, so it will always have this issue. And I see no way to ‘repair’ the file with the robot, since there is no excel installed I cannot open Excel and let the robot change and save it and whenever I use readRange I don’t get the correct headers ;-(.
I tried several combinations of read range/table range with and without header and preserve format none lead to an acceptable result. But in the meantime I convinced IT to install Excel on the machine, so that is going to be the solution.
If IT had refused to install Excel I would have used the ‘brute force’-method: completely skip the header line and hardcode the headers instead (as they will be stable for at a longer period)