Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix table transform #43

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
]