How to check if XLSX file empty

Read range activity is not working when the file is empty.

We need to store the value into Data table only if file has data .

@Sathish_Kumar_S

YourDataTable = If(File.ReadAllLines(“YourFilePath”).Length > 0, YourDataTable, New DataTable)

This expression checks if the file has data. If it does, it uses the Read Range activity to load the data into YourDataTable. If the file is empty, it initializes YourDataTable as a new DataTable.

Hey @Sathish_Kumar_S
Excel application scope is better because returns ‘null’ value which you can handle.
image

For read range workbook I can suggest to use try catch activity.

Hi @Sathish_Kumar_S ,
You can use 'Read range ’ inside 'Excel Scope "
then check Data.RowCount = 0


hope it help,

@Sathish_Kumar_S
If Excel is not installed in your environment or some other reasons so that you have to use workbook activities, you may add a try catch with ‘NullReferenceException’.
image

Hi @Sathish_Kumar_S ,

Good Day.

I feel we have only two options to handle this, either check the count before you read the excel or handle the Null expectation.

Thanks
Muthu