|
NanoXLSX.Core 3.0.0-rc.3
|
General data utils class with static methods. More...
Public Types | |
| enum | RangeMergeStrategy { NoMerge , MergeColumns , MergeRows } |
| Strategy how ranges should be merged. More... | |
Static Public Member Functions | |
| static string | GetOADateTimeString (DateTime date) |
| Method to convert a date or date and time into the internal Excel time format (OAdate). | |
| static double | GetOADateTime (DateTime date, bool skipCheck=false) |
| Method to convert a date or date and time into the internal Excel time format (OAdate). | |
| static string | GetOATimeString (TimeSpan time) |
| Method to convert a time into the internal Excel time format (OAdate without days). | |
| static double | GetOATime (TimeSpan time) |
| Method to convert a time into the internal Excel time format (OAdate without days). | |
| static DateTime | GetDateFromOA (double oaDate) |
| Method to calculate a common Date from the OA date (OLE automation) format OA Date format starts at January 1st 1900 (actually 00.01.1900). Dates beyond this date cannot be handled by Excel under normal circumstances and will throw a FormatException. | |
| static float | GetInternalColumnWidth (float columnWidth, float maxDigitWidth=7f, float textPadding=5f) |
| Calculates the internal width of a column in characters. This width is used only in the XML documents of worksheets and is usually not exposed to the (Excel) end user. | |
| static float | GetInternalRowHeight (float rowHeight) |
| Calculates the internal height of a row. This height is used only in the XML documents of worksheets and is usually not exposed to the (Excel) end user. | |
| static float | GetInternalPaneSplitWidth (float width, float maxDigitWidth=7f, float textPadding=5f) |
| Calculates the internal width of a split pane in a worksheet. This width is used only in the XML documents of worksheets and is not exposed to the (Excel) end user. | |
| static float | GetInternalPaneSplitHeight (float height) |
| Calculates the internal height of a split pane in a worksheet. This height is used only in the XML documents of worksheets and is not exposed to the (Excel) user. | |
| static float | GetPaneSplitHeight (float internalHeight) |
| Calculates the height of a split pane in a worksheet, based on the internal value (calculated by GetInternalPaneSplitHeight(float)). | |
| static float | GetPaneSplitWidth (float internalWidth, float maxDigitWidth=7f, float textPadding=5f) |
| Calculates the width of a split pane in a worksheet, based on the internal value (calculated by GetInternalPaneSplitWidth(float, float, float)). | |
| static IReadOnlyList< Range > | MergeRange (List< Range > givenRanges, Range newRange, RangeMergeStrategy strategy=RangeMergeStrategy.MergeColumns) |
| Merges a range with a list of given ranges. If there is no intersection between the list and the new range, the range is just added to the given list. If there is an intersection, the range will be merged and the new list of ranges will be returned. | |
| static IReadOnlyList< Range > | SubtractRange (List< Range > givenRanges, Range rangeToRemove, RangeMergeStrategy strategy=RangeMergeStrategy.MergeColumns) |
| Subtracts a range form a list of given ranges. If the range to be removed does not intersect any of the given ranges, nothing happens. If the range intersects at least one of the given ranges, the intersection will be removed and the new ranges well be returned. | |
Static Public Attributes | |
| static readonly double | MinOADateValue = 0d |
| Minimum valid OAdate value (1900-01-01). However, Excel displays this value as 1900-01-00 (day zero). | |
| static readonly double | MaxOADateValue = 2958465.999988426d |
| Maximum valid OAdate value (9999-12-31). | |
| static readonly DateTime | FirstAllowedExcelDate = new DateTime(1900, 1, 1, 0, 0, 0, DateTimeKind.Unspecified) |
| First date that can be displayed by Excel. Real values before this date cannot be processed. | |
| static readonly DateTime | LastAllowedExcelDate = new DateTime(9999, 12, 31, 23, 59, 59, DateTimeKind.Unspecified) |
| Last date that can be displayed by Excel. Real values after this date cannot be processed. | |
| static readonly DateTime | FirstValidExcelDate = new DateTime(1900, 3, 1, 0, 0, 0, DateTimeKind.Unspecified) |
| All dates before this date are shifted in Excel by -1.0, since Excel assumes wrongly that the year 1900 is a leap year. See also: https://docs.microsoft.com/en-us/office/troubleshoot/excel/wrongly-assumes-1900-is-leap-year. | |
| static readonly CultureInfo | InvariantCulture = CultureInfo.InvariantCulture |
| Constant for number conversions. The invariant culture (represents mostly the US numbering scheme) ensures that no culture-specific punctuations are used when converting numbers to strings, This is especially important for OOXML number values. See also: https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.invariantculture?view=net-5.0. | |
General data utils class with static methods.
Definition at line 19 of file DataUtils.cs.
Strategy how ranges should be merged.
| Enumerator | |
|---|---|
| NoMerge | No merge should be performed. |
| MergeColumns | Ranges of the same columns should be merged. |
| MergeRows | Ranges of the same row should be merged. |
Definition at line 74 of file DataUtils.cs.
|
static |
Method to calculate a common Date from the OA date (OLE automation) format
OA Date format starts at January 1st 1900 (actually 00.01.1900). Dates beyond this date cannot be handled by Excel under normal circumstances and will throw a FormatException.
| oaDate | oaDate OA date number |
Definition at line 175 of file DataUtils.cs.
|
static |
Calculates the internal width of a column in characters. This width is used only in the XML documents of worksheets and is usually not exposed to the (Excel) end user.
| columnWidth | Target column width (displayed in Excel) |
| maxDigitWidth | Maximum digit with of the default font (default is 7.0 for Calibri, size 11) |
| textPadding | Text padding of the default font (default is 5.0 for Calibri, size 11) |
| FormatException | Throws a FormatException if the column width is out of range |
Definition at line 201 of file DataUtils.cs.
|
static |
Calculates the internal height of a split pane in a worksheet. This height is used only in the XML documents of worksheets and is not exposed to the (Excel) user.
| height | Target row(s) height (one or more rows, displayed in Excel) |
Definition at line 286 of file DataUtils.cs.
|
static |
Calculates the internal width of a split pane in a worksheet. This width is used only in the XML documents of worksheets and is not exposed to the (Excel) end user.
| width | Target column(s) width (one or more columns, displayed in Excel) |
| maxDigitWidth | Maximum digit with of the default font (default is 7.0 for Calibri, size 11) |
| textPadding | Text padding of the default font (default is 5.0 for Calibri, size 11) |
Definition at line 259 of file DataUtils.cs.
|
static |
Calculates the internal height of a row. This height is used only in the XML documents of worksheets and is usually not exposed to the (Excel) end user.
| rowHeight | Target row height (displayed in Excel) |
| FormatException | Throws a FormatException if the row height is out of range |
Definition at line 230 of file DataUtils.cs.
|
static |
Method to convert a date or date and time into the internal Excel time format (OAdate).
| skipCheck | Optional flag to skip the validity check if set to true |
| date | Date to process |
| NanoXLSX.Exceptions.FormatException | Throws a FormatException if the passed date cannot be translated to the OADate format |
Definition at line 126 of file DataUtils.cs.
|
static |
Method to convert a date or date and time into the internal Excel time format (OAdate).
| date | Date to process |
| NanoXLSX.Exceptions.FormatException | Throws a FormatException if the passed date cannot be translated to the OADate format |
Definition at line 105 of file DataUtils.cs.
|
static |
Method to convert a time into the internal Excel time format (OAdate without days).
| time | Time to process. The date component of the timespan is converted to the total numbers of days |
Definition at line 159 of file DataUtils.cs.
|
static |
Method to convert a time into the internal Excel time format (OAdate without days).
| time | Time to process. The date component of the timespan is converted to the total numbers of days |
Definition at line 147 of file DataUtils.cs.
|
static |
Calculates the height of a split pane in a worksheet, based on the internal value (calculated by GetInternalPaneSplitHeight(float)).
| internalHeight | Internal pane height stored in a worksheet. The minimal value is defined by SPLIT_HEIGHT_POINT_OFFSET |
Definition at line 302 of file DataUtils.cs.
|
static |
Calculates the width of a split pane in a worksheet, based on the internal value (calculated by GetInternalPaneSplitWidth(float, float, float)).
| internalWidth | Internal pane width stored in a worksheet. The minimal value is defined by SPLIT_WIDTH_POINT_OFFSET |
| maxDigitWidth | Maximum digit with of the default font (default is 7.0 for Calibri, size 11) |
| textPadding | Text padding of the default font (default is 5.0 for Calibri, size 11) |
Definition at line 323 of file DataUtils.cs.
|
static |
Merges a range with a list of given ranges. If there is no intersection between the list and the new range, the range is just added to the given list. If there is an intersection, the range will be merged and the new list of ranges will be returned.
| givenRanges | List of given ranges |
| newRange | The range to be merged |
| strategy | Strategy for the range recalculation. Depending on the value, the resulting ranges are either merged along rows, along columns (default), or not merged at all |
Definition at line 345 of file DataUtils.cs.
|
static |
Subtracts a range form a list of given ranges. If the range to be removed does not intersect any of the given ranges, nothing happens. If the range intersects at least one of the given ranges, the intersection will be removed and the new ranges well be returned.
| givenRanges | List of given ranges |
| rangeToRemove | The range to be removed |
| strategy | Strategy for the range recalculation. Depending on the value, the resulting ranges are either merged along rows, along columns (default), or not merged at all |
Definition at line 429 of file DataUtils.cs.
|
static |
First date that can be displayed by Excel. Real values before this date cannot be processed.
Definition at line 36 of file DataUtils.cs.
|
static |
All dates before this date are shifted in Excel by -1.0, since Excel assumes wrongly that the year 1900 is a leap year.
See also: https://docs.microsoft.com/en-us/office/troubleshoot/excel/wrongly-assumes-1900-is-leap-year.
Definition at line 47 of file DataUtils.cs.
|
static |
Constant for number conversions. The invariant culture (represents mostly the US numbering scheme) ensures that no culture-specific punctuations are used when converting numbers to strings, This is especially important for OOXML number values. See also: https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.invariantculture?view=net-5.0.
Definition at line 55 of file DataUtils.cs.
|
static |
Last date that can be displayed by Excel. Real values after this date cannot be processed.
Definition at line 40 of file DataUtils.cs.
|
static |
Maximum valid OAdate value (9999-12-31).
Definition at line 32 of file DataUtils.cs.
|
static |
Minimum valid OAdate value (1900-01-01). However, Excel displays this value as 1900-01-00 (day zero).
Definition at line 27 of file DataUtils.cs.