Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F#Excel范围。自动筛选()失败_F#_Vsto_Excel 2010_Excel Interop - Fatal编程技术网

F#Excel范围。自动筛选()失败

F#Excel范围。自动筛选()失败,f#,vsto,excel-2010,excel-interop,F#,Vsto,Excel 2010,Excel Interop,我正在尝试为将使用数据的用户启用AutoFilter open Microsoft.Office.Interop.Excel let xl = ApplicationClass() xl.Workbooks.OpenText(fileName...) let wb = xl.Workbooks.Item(1) let ws = wb.ActiveSheet :?> Worksheet let rows = string ws.UsedRange.Rows.Count // AutoF

我正在尝试为将使用数据的用户启用
AutoFilter

open Microsoft.Office.Interop.Excel

let xl = ApplicationClass()
xl.Workbooks.OpenText(fileName...)
let wb = xl.Workbooks.Item(1)
let ws = wb.ActiveSheet :?> Worksheet

let rows = string ws.UsedRange.Rows.Count

// AutoFilter method of Range class failed.
ws.Range("A7:I" + rows).AutoFilter() |> ignore
感谢您提供的帮助。

根据,您需要将5个参数传递给
自动筛选

未指定的参数可由填写

差不多

ws.Range("A7:I" + rows).AutoFilter(1, System.Reflection.Missing.Value, 
                                   Excel.XlAutoFilterOperator.xlAnd, 
                                   System.Reflection.Missing.Value, true) 
|> ignore

应该可以工作。

公平地说,Intellisense和文档都表明所有参数都是可选的,文档表明省略所有参数只是切换自动筛选下拉箭头的显示,这正是我想要的。我不得不这么说,这样我才不觉得自己是个十足的白痴<代码>类型。缺少的在我的计算机上不起作用(名称空间或模块“Type”未定义),因此我将它们替换为
“”
,并对其进行编译。不幸的是,它会导致过滤整个范围而不显示任何内容。我也尝试了
,每个文档都有相同的结果;我不熟悉Excel互操作<代码>类型.缺少的应该是
系统.Reflection.Missing.Value
。我不知道为什么没有什么可以显示,你最好的选择是改变选项,确保你有真实的数据可以过滤。啊!成功了!非常感谢你!没有参数的调用应该只切换AutoFilter下拉箭头的显示,这就是我所要做的。