我在文檔庫中有一個用戶可編輯的Excel文件,它定義了F#程序的一些輸入。我想用F#-y讀取它,所以我想我會試用FSharpX和它們的ExcelFile類型提供程序。F#類型提供者FSharpX.ExcelFile和試圖在不同輸入上構造的奇怪類型錯誤
什麼工作
提供商通過的NuGet安裝並啓用,這一點也適用:
open FSharpX
type Example = ExcelFile<"example.xlsx", "Worksheet1", true>
let file = new Example()
for row in File.Data do ......
什麼不
然而,當我嘗試用不同的初始化構造文件(我在運行時從數據庫中取出並保存在臨時位置),我得到了一個非常奇怪的類型錯誤。
let file = new Example(@"c:\temp\path\to.xlsx")
結果
The type provider 'FSharpx.TypeProviders.ExcelProvider+ExcelProvider' reported an error in the context of provided type 'FSharpx.ExcelFile,filename="example.xlsx",sheetname="Worksheet1",forcestring="True"', member '.ctor'. The error: Type mismatch when splicing expression into quotation literal. The type of the expression tree being inserted doesn't match the type expected by the splicing operation. Expected 'System.String', but received type 'System.Tuple`2[System.String,System.String]'. Consider type-annotating with the expected expression type, e.g., (%% x : string) or (%x : string). Parameter name: receivedType
咦?
我不知道它所說的元組可能來自哪裏,我也沒有任何關於如何初始化它的其他想法。
紅利問題:如果我想在運行時改變工作表名稱,該怎麼辦?現有的FSharpx提供者似乎不允許這樣做。
OK,只是檢查,我想我是瘋了還是做錯了什麼。將提交一個錯誤。 – 2013-04-26 02:02:02
此錯誤已修復:https://github.com/fsharp/fsharpx/commit/e9912d9cb68cedd723e351748c47f9fefc7bbb3d(請參見行154) – 2013-05-09 15:33:11