Skip to content
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
10 changes: 7 additions & 3 deletions src/ExcelProvider/ExcelAddressing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@ let getRangeView (workbook : DataSet) range =
///Gets a View object which can be used to read data from the given range in the DataSet
let public getView (workbook : DataSet) range =
let worksheets = workbook.Tables
let firstWorkSheetName = worksheets.[0].TableName

let workSheetName =
if worksheets.Contains range
then range
else worksheets.[0].TableName

let ranges =
parseExcelRanges firstWorkSheetName range
let ranges =
parseExcelRanges workSheetName range
|> List.map (getRangeView workbook)

let minRow = ranges |> Seq.map (fun range -> range.StartRow) |> Seq.min
Expand Down
29 changes: 28 additions & 1 deletion tests/ExcelProvider.Tests/ExcelProvider.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type MultipleRegions = ExcelFile<"MultipleRegions.xlsx", "A1:C5,E3:G5", true>
type DifferentMainSheet = ExcelFile<"DifferentMainSheet.xlsx">
type DataTypes = ExcelFile<"DataTypes.xlsx">

type MultipleSheetsFirst = ExcelFile<"MultipleSheets.xlsx", "A">
type MultipleSheetsSecond = ExcelFile<"MultipleSheets.xlsx", "B">

[<Test>]
let ``Read Text as String``() =
let file = DataTypes()
Expand Down Expand Up @@ -173,4 +176,28 @@ let ``Can load from multiple ranges``() =
rows.[3].Third |> should equal "A12"
rows.[3].Fourth |> should equal null
rows.[3].Fifth |> should equal null
rows.[3].Sixth |> should equal null
rows.[3].Sixth |> should equal null

[<Test>]
let ``Can load from first multiple sheets - first``() =
let file = MultipleSheetsFirst()
let rows = file.Data |> Seq.toArray

rows.[0].First |> should equal 1.0
rows.[0].Second |> should equal false
rows.[0].Third |> should equal "a"

rows.[1].First |> should equal 2.0
rows.[1].Second |> should equal true
rows.[1].Third |> should equal "b"

[<Test>]
let ``Can load from first multiple sheets - second``() =
let file = MultipleSheetsSecond()
let rows = file.Data |> Seq.toArray

rows.[0].Fourth |> should equal 2.2
rows.[0].Fifth |> should equal (new DateTime(2013,1,1))

rows.[1].Fourth |> should equal 3.2
rows.[1].Fifth |> should equal (new DateTime(2013,2,1))
Binary file added tests/ExcelProvider.Tests/MultipleSheets.xlsx
Binary file not shown.