diff --git a/PanoramicData.SheetMagic/MagicSpreadsheet.CellOperations.cs b/PanoramicData.SheetMagic/MagicSpreadsheet.CellOperations.cs index 9295bc0..83a783c 100644 --- a/PanoramicData.SheetMagic/MagicSpreadsheet.CellOperations.cs +++ b/PanoramicData.SheetMagic/MagicSpreadsheet.CellOperations.cs @@ -123,11 +123,7 @@ private static string GetCellValueString(Cell cell, SharedStringTablePart? strin if (cell.DataType != null && (CellValues)cell.DataType == CellValues.SharedString) { - if (stringTable?.SharedStringTable is null || cellValueText == null) - { - return string.Empty; - } - return stringTable.SharedStringTable.ElementAt(int.Parse(cellValueText)).InnerText; + return GetSharedStringValue(stringTable, cellValueText); } return cellValueText ?? cell.InnerText; @@ -390,10 +386,8 @@ private static string GetSharedStringValue(SharedStringTablePart? stringTable, s var stringTableIndex = int.Parse(cellValueText); var sharedStringElement = stringTable.SharedStringTable.ElementAt(stringTableIndex); - var sharedStringValue = sharedStringElement.InnerText; - // Handle special Infinity values for object-typed cells - return TryParseInfinityForObject(sharedStringValue) ?? (object)sharedStringValue; + return TryParseInfinityForObject(sharedStringElement.InnerText) ?? (object)sharedStringElement.InnerText; } /// @@ -406,12 +400,7 @@ private static string GetSharedStringValue(SharedStringTablePart? stringTable, s : null; private static bool? ParseBooleanValueTyped(string? cellValueText) - => cellValueText switch - { - "1" or "true" => true, - "0" or "false" => false, - _ => null, - }; + => ParseBooleanValue(cellValueText); private static double ParseNumberTyped(string? cellValueText) {