fsprojects / ExcelProvider

This library is for the .NET platform implementing a Excel type provider.
http://fsprojects.github.io/ExcelProvider/
The Unlicense
141 stars 51 forks source link

Cannot load excel file at runtime #36

Open matteo-mosca opened 7 years ago

matteo-mosca commented 7 years ago

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.

ppalmerjm commented 7 years ago

One would expect that to work something like the Linq to Sql provider.

Or more like a .dbml file where you can specify that

diegobfernandez commented 7 years ago

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"
StefanBelo commented 7 years ago

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.

ArtemyB commented 7 years ago

@diegobfernandez thanks for the tip, it worked for me. It's great I've stumbled upon your comment. 👍