Skip to content

Commit

Permalink
Merge pull request #43 from CSBiology/fixTableTransform
Browse files Browse the repository at this point in the history
Fix table transform
  • Loading branch information
HLWeil committed Jul 25, 2023
2 parents e9f7f53 + 1ee068c commit 64f86ec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/FsSpreadsheet.ExcelIO/FsExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

/// <summary>
/// Returns the FsWorksheet associated with the FsTable in a given FsWorkbook.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<Compile Include="OpenXml\Sheet.fs" />
<Compile Include="OpenXml\Workbook.fs" />
<Compile Include="OpenXml\Spreadsheet.fs" />
<Compile Include="Table.fs" />
<Compile Include="FsWorkbook.fs" />
<Compile Include="Main.fs" />
</ItemGroup>
Expand Down
25 changes: 25 additions & 0 deletions tests/FsSpreadsheet.ExcelIO.Tests/Table.fs
Original file line number Diff line number Diff line change
@@ -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
)

]


[<Tests>]
let main =
testList "FsTable" [
transformTable
]

0 comments on commit 64f86ec

Please sign in to comment.