NanoXLSX.Core 3.2.1
Loading...
Searching...
No Matches
Errors.cs
1/*
2 * NanoXLSX is a small .NET library to generate and read XLSX (Microsoft Excel 2007 or newer) files in an easy and native way
3 * Copyright Raphael Stoeckli © 2026
4 * This library is licensed under the MIT License.
5 * You find a copy of the license in project folder or on: http://opensource.org/licenses/MIT
6 */
7
8using System;
9
11{
15 public static class Errors
16 {
66
67 //TODO Expose public?
75 internal static bool TryParseFormulaError(string value, out FormulaError error)
76 {
77 switch (value)
78 {
79 case "#NULL!":
80 error = FormulaError.Null;
81 return true;
82 case "#DIV/0!":
83 error = FormulaError.DivisionByZero;
84 return true;
85 case "#VALUE!":
86 error = FormulaError.Value;
87 return true;
88 case "#REF!":
89 error = FormulaError.Reference;
90 return true;
91 case "#NAME?":
92 error = FormulaError.Name;
93 return true;
94 case "#NUM!":
95 error = FormulaError.Number;
96 return true;
97 case "#N/A":
98 error = FormulaError.NotAvailable;
99 return true;
100 case "#GETTING_DATA":
101 error = FormulaError.GettingData;
102 return true;
103 default:
104 error = FormulaError.UnknownError;
105 return false;
106 }
107 }
108
109 //TODO Expose public?
116 internal static string FormulaErrorToString(FormulaError error)
117 {
118 switch (error)
119 {
120 case FormulaError.Null:
121 return "#NULL!";
122 case FormulaError.DivisionByZero:
123 return "#DIV/0!";
124 case FormulaError.Value:
125 return "#VALUE!";
126 case FormulaError.Reference:
127 return "#REF!";
128 case FormulaError.Name:
129 return "#NAME?";
130 case FormulaError.Number:
131 return "#NUM!";
132 case FormulaError.NotAvailable:
133 return "#N/A";
134 case FormulaError.GettingData:
135 return "#GETTING_DATA";
136 default:
137 throw new FormatException($"An invalid error type '{error}' was specified");
138 }
139 }
140 }
141}
Static class that contains shared enums for error cases.
Definition Errors.cs:16
FormulaError
Errors that can occur in formulas / functions.
Definition Errors.cs:21
@ GettingData
Indicate that a cell reference cannot be evaluated because the value for the cell has not been retrie...
Definition Errors.cs:64
@ DivisionByZero
Indicates that any number (including zero) or any error code is divided by zero.
Definition Errors.cs:37
@ Name
Indicates that what looks like a name is used, but no such name has been defined.
Definition Errors.cs:49
@ NotAvailable
Indicates that a designated value is not available.
Definition Errors.cs:59
@ Reference
Indicate that a cell reference cannot be evaluated.
Definition Errors.cs:45
@ Value
Indicates that an incompatible type argument is passed to a function, or an incompatible type operand...
Definition Errors.cs:41
@ NoError
Default value if no error has occurred (not an actual error type).
Definition Errors.cs:25
@ Number
Indicates that an argument to a function has a compatible type, but has a value that is outside the d...
Definition Errors.cs:54
@ Null
Indicates that two areas are required to intersect, but do not.
Definition Errors.cs:33
@ UnknownError
Value if a not yet defined value has occurred (not an actual error type).
Definition Errors.cs:29