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 a 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 an Excel file. The code loads the sample Excel file which throws a DuplicateDefinedName warning when 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 the output Excel file. If you open the sample Excel file in Microsoft Excel, it will also display this warning to you as shown in this screenshot. Please also check the console output of the code given below for better 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