Enum ExceptionType

ExceptionType enumeration

Represents custom exception type code.

public enum ExceptionType

Values

NameValueDescription
Chart0Invalid chart setting.
DataType1Invalid data type setting.
DataValidation2Invalid data validation setting.
ConditionalFormatting3Invalid data validation setting.
FileFormat4Invalid file format.
Formula5Invalid formula.
InvalidData6Invalid data.
InvalidOperator7Invalid operator.
IncorrectPassword8Incorrect password.
License9License related errors.
Limitation10Out of MS Excel limitation error.
PageSetup11Invalid page setup setting.
PivotTable12Invalid pivotTable setting.
Shape13Invalid drawing object setting.
Sparkline14Invalid sparkline object setting.
SheetName15Invalid worksheet name.
SheetType16Invalid worksheet type.
Interrupted17The process is interrupted.
IO18The file is invalid.
Permission19Permission is required to open this file.
UnsupportedFeature20Unsupported feature.
UnsupportedStream21Unsupported stream to be opened.
UndisclosedInformation22Files contains some undisclosed information.
FileCorrupted23File content is corrupted.
DefinedName25Invalid defined name
Font26Invalid font
AutoFilter27Invalid auto filter setting.
FontSubstitution28Font substitution warning type when a font has not been found, this warning type can be get.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;

    public class ExceptionTypeDemo
    {
        public static void ExceptionTypeExample()
        {
            try
            {
                // Create a new workbook
                Workbook workbook = new Workbook();

                // Attempt to set an invalid worksheet name to trigger an exception
                workbook.Worksheets[0].Name = "Invalid/Name";

                // Save the workbook
                workbook.Save("ExceptionTypeExample.xlsx");
            }
            catch (CellsException ex)
            {
                // Handle the CellsException
                Console.WriteLine("An error occurred: " + ex.Message);
                Console.WriteLine("Exception Type Code: " + ex.Code);
                
                // Check the type of exception
                switch (ex.Code)
                {
                    case ExceptionType.SheetName:
                        Console.WriteLine("The worksheet name is invalid.");
                        break;
                    case ExceptionType.FileFormat:
                        Console.WriteLine("The file format is invalid.");
                        break;
                    // Add more cases as needed for different exception types
                    default:
                        Console.WriteLine("An unknown error occurred.");
                        break;
                }
            }
            catch (Exception ex)
            {
                // Handle any other exceptions
                Console.WriteLine("An unexpected error occurred: " + ex.Message);
            }
        }
    }
}

See Also