Why does getAllData() read Excel file data incorrectly?
The origin and compare Excel file sheets cannot be compared by themselves, so the compare row is verified to exist in the origin.
By the way, when reading a compare row, why can’t I read an entire line?
In the following image,
the red data (210…) is reading and processing the values in the line directly below. Is this a Katalon error?
My code is in the following.
excel.zip (22.9 KB)
Here are origin and compare excel file. The main code is in the following. The compare excel file(N*.xls) corresponds to dynamicsheet. and it happended for all excel files.
It seems to me that you expect your test script compares these 2 sheets and find out that they are identical. But the 2 Excel sheets you shared are different, as the following screenshot shows.
My goal is not to verify that the two sheets are identical, but to verify whether the contents of the COMPARE sheet are at ORIGIN or not.
I’ve already known that some rows in the COMPARE sheet may not be in the ORIGIN sheet. There are 50 more sheets to compare. All of these sheets may be the same or different.
However, there seems to be a problem with the getAllData() function. I hope you can confirm this.
When using getdAllData(), the last line of the COMPARE sheet was not printed. The reason is that the problem is that one row is not completely read, as verified in the screen shot below.
public static ExcelData getExcelDataWithDefaultSheet(String fullFilePath, String sheetName, boolean hasHeaders)
If you give true to the 3rd argument, then the ExcelData object will regard the 1st row of the sheet as Header not as a data row.
It is likely that the ExcelData object got confused. When I had a look at the sheet you shared, the 1st row of sheets looks empty. However, at the API level, there are several possible cases:
the 1st row does not exist, request to Sheet to return the 1st row it returns null
the 1st row does exists but has no cell
the 1st row does exists and has one or more cell with empty content
the 1st row does exists and has one or more cell with whitespace content
Which case applies to your sheets? Does the 1st row of your sheets “exists” or not? I do not know. But the above 4 cases may affect the behavior of getAllData().
Your Excel sheets have a complex format; they are not as simple as Katalon’s builtin ExcelData class assumes. It assumes that a sheet has zero or one header row followed by a set of data rows in a uniform format. On the other hand, your sheet has a few internal "grid"s inside, each has a title part and a data part.
IMHO, you should not use the Katalon built-in ExcelData class. Rather you should use the Apache POI library directly so that your script can parse the sheet to recognize your sheet format correctly.You can import the Apache POI classes in your test case scripts. But, I am afraid, programming it requires some efforts.