From 1ee068c9c0f8f0c42137defb2837c8c54308dbc6 Mon Sep 17 00:00:00 2001 From: Heinrich Lukas Weil Date: Tue, 25 Jul 2023 11:09:01 +0400 Subject: [PATCH] fix and test #42 --- src/FsSpreadsheet.ExcelIO/FsExtensions.fs | 3 ++- .../FsSpreadsheet.ExcelIO.Tests.fsproj | 1 + tests/FsSpreadsheet.ExcelIO.Tests/Table.fs | 25 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/FsSpreadsheet.ExcelIO.Tests/Table.fs diff --git a/src/FsSpreadsheet.ExcelIO/FsExtensions.fs b/src/FsSpreadsheet.ExcelIO/FsExtensions.fs index 68585fb7..70855167 100644 --- a/src/FsSpreadsheet.ExcelIO/FsExtensions.fs +++ b/src/FsSpreadsheet.ExcelIO/FsExtensions.fs @@ -78,7 +78,8 @@ module FsExtensions = static member fromXlsxTable table = let topLeftBoundary, bottomRightBoundary = Table.getArea table |> Table.Area.toBoundaries let ra = FsRangeAddress(FsAddress(topLeftBoundary), FsAddress(bottomRightBoundary)) - FsTable(table.Name, ra, table.TotalsRowShown, true) + let totalsRowShown = if table.TotalsRowShown = null then false else table.TotalsRowShown.Value + FsTable(table.Name, ra, totalsRowShown, true) /// /// Returns the FsWorksheet associated with the FsTable in a given FsWorkbook. diff --git a/tests/FsSpreadsheet.ExcelIO.Tests/FsSpreadsheet.ExcelIO.Tests.fsproj b/tests/FsSpreadsheet.ExcelIO.Tests/FsSpreadsheet.ExcelIO.Tests.fsproj index 735a8349..480cb7b9 100644 --- a/tests/FsSpreadsheet.ExcelIO.Tests/FsSpreadsheet.ExcelIO.Tests.fsproj +++ b/tests/FsSpreadsheet.ExcelIO.Tests/FsSpreadsheet.ExcelIO.Tests.fsproj @@ -14,6 +14,7 @@ + diff --git a/tests/FsSpreadsheet.ExcelIO.Tests/Table.fs b/tests/FsSpreadsheet.ExcelIO.Tests/Table.fs new file mode 100644 index 00000000..4803a568 --- /dev/null +++ b/tests/FsSpreadsheet.ExcelIO.Tests/Table.fs @@ -0,0 +1,25 @@ +module FsTable + +open Expecto +open FsSpreadsheet +open FsSpreadsheet.ExcelIO +open DocumentFormat.OpenXml +open TestingUtils + + +let transformTable = + testList "transformTable" [ + testCase "handleNullFields" (fun () -> + let table = FsSpreadsheet.ExcelIO.Table.create "TestTable" (StringValue ("A1:D4")) [] + Expect.isTrue (table.TotalsRowShown = null) "Check that field of interest is None" + FsTable.fromXlsxTable table |> ignore + ) + + ] + + +[] +let main = + testList "FsTable" [ + transformTable + ]