ExcelProvider icon indicating copy to clipboard operation
ExcelProvider copied to clipboard

Cannot load excel file at runtime

Open matteo-mosca opened this issue 8 years ago • 4 comments

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.

matteo-mosca avatar Jan 27 '17 09:01 matteo-mosca

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.

ppalmerjm avatar Jan 27 '17 20:01 ppalmerjm

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"

diegobfernandez avatar Feb 12 '17 20:02 diegobfernandez

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.

StefanBelo avatar Mar 10 '17 16:03 StefanBelo

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

ArtemyB avatar Jun 22 '17 13:06 ArtemyB