Get Warnings while Loading Excel File

Possible Usage Scenarios

Sometimes the user tries to load the workbook which is somewhat corrupt but loadable. In such case, Aspose.Cells throws warnings while loading the workbook. You can catch these warnings by implementing the IWarningCallback interface and setting LoadOptions.WarningCallback property.

Get Warnings while Loading Excel File

The following sample code explains how to get warnings while loading excel file. The code loads the sample excel file which throws DuplicateDefinedName warning on loading. This warning is then caught by IWarningCallback.Warning() method that prints the warning messages on the console. The code then saves the workbook as output excel file. If you open the sample excel file in Microsoft Excel, it will also display you this warning as shown in this screenshot. Please also check the console output of the code given below for more understanding.

todo:image_alt_text

Sample Code

Console Output

Here is the console output of the above code when executed with the provided sample excel file.

Duplicate Defined Name Warning: Name:PRINT_AREA;ReferTo:Introduction!$D$16:$D$17

Duplicate Defined Name Warning: Name:PRINT_AREA;ReferTo:Panel!$B$228

Duplicate Defined Name Warning: Name:PRINT_AREA;ReferTo:'Queries '!$D$14:$D$16