ExcelProvider
ExcelProvider copied to clipboard
Cannot load excel file at runtime
Description
I can't find a way to load an excel file at runtime. I can only use the one specified as a constant in the type provider initialization
Repro steps
There are no steps to reproduce this problem.
Expected behavior
I expect to use the the constant file as a "template" and then be able to specify at runtime which file to parse, which will need to have the same structure of the template. Withtout this possibility the type provider is useless in real applications.
Actual behavior
I can only load and parse the file I provide as a constant string in the type provider initialization. In other type providers I have used there is a "Load" method to call with a path parameter to specify a different file.
Known workarounds
No workarounds found.
One would expect that to work something like the Linq to Sql provider.
Or more like a .dbml file where you can specify that
- the template looks like a file XTemplate.xlsx in the current directory
- and the Excel file(s) to parse can be found in some other directory with the format ActualFile2Parse * .xlsx.
Have you tried invoking the type constructor with a file path? Check the source: https://github.com/fsprojects/ExcelProvider/blob/master/src/ExcelProvider/ExcelProvider.fs#L192
type MyExcel = ExcelFile<"excel.xlsx">
let excel = MyExcel "another-excel.xlsx"
I have got the same problem. What you suggest:
type MyExcel = ExcelFile<"excel.xlsx"> let excel = MyExcel "another-excel.xlsx"
Does not load data from "another-excel.xlsx". Processing data ends with:
Exception thrown: 'System.OverflowException'
It seems new data are not loaded, nor iteration through data works, it is always loaded first row from template excel file ExcelFile<"excel.xlsx">, in never-ending loop. Exception ends data processing.
@diegobfernandez thanks for the tip, it worked for me. It's great I've stumbled upon your comment. 👍