C# ClosedXML使用path创建现有工作簿时出现异常

C# ClosedXML使用path创建现有工作簿时出现异常,c#,winforms,closedxml,C#,Winforms,Closedxml,我正在Windows窗体应用程序中使用ClosedXML打开和读取Excel文件 if (openFileDialog1.ShowDialog(this) == DialogResult.OK) { string path = openFileDialog1.InitialDirectory + openFileDialog1.FileName; dt = ImportInDataTable(path, wrksheet); datagridReview.DataSource

我正在Windows窗体应用程序中使用ClosedXML打开和读取Excel文件

if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
   
  string path = openFileDialog1.InitialDirectory + openFileDialog1.FileName;
  dt = ImportInDataTable(path, wrksheet);
  datagridReview.DataSource = dt;
                
}
“路径”的用法如下:

XLWorkbook workbook = new XLWorkbook(path);
"C:\\Projects\\test.xlsx"
path变量内容如下所示:

XLWorkbook workbook = new XLWorkbook(path);
"C:\\Projects\\test.xlsx"
尝试使用path设置工作簿对象后,出现异常“System.FormatException:文本值不是有效的枚举值”

这段代码与今天早些时候编写的一样有效。我不明白这个例外是什么意思

感谢您的帮助。 瑞安

编辑1-添加堆栈跟踪

   *at DocumentFormat.OpenXml.EnumValue`1.GetEnumValue(String stringVal)
   at DocumentFormat.OpenXml.EnumValue`1.Parse()
   at DocumentFormat.OpenXml.EnumValue`1.get_Value()
   at ClosedXML.Excel.XLWorkbook.LoadAutoFilterColumns(AutoFilter af, XLAutoFilter autoFilter)
   at ClosedXML.Excel.XLWorkbook.LoadAutoFilter(AutoFilter af, XLWorksheet ws)
   at ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet)
   at ClosedXML.Excel.XLWorkbook.LoadSheets(String fileName)
   at ClosedXML.Excel.XLWorkbook..ctor(String file)
   at PTSImport.Import.ImportInDataTable(String path, Int32 wrksheet) in C:\Repos\PTS\Importer\PTS-Importer\PTSImport\Import.cs:line 309
   at PTSImport.Import.buttonOpenFile_Click(Object sender, EventArgs e) in C:\Repos\PTS\Importer\PTS-Importer\PTSImport\Import.cs:line 46
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at PTSImport.Program.Main() in C:\Repos\PTS\Importer\PTS-Importer\PTSImport\Program.cs:line 19*
编辑:
由于时间紧迫,我恢复使用MS Excel Interop对象

请将完整堆栈跟踪添加到您的问题中。Francois Botha-我添加了堆栈跟踪