如何使用 阅读受密码保护的 Excel 工作簿ExcelQueryFactory
?
我可以使用下面的代码在没有密码保护的情况下读取 excel。
var excel = new ExcelQueryFactory();
excel.FileName = "path of excel file";
但是当excel受密码保护时,上面的代码会失败。
如何使用 阅读受密码保护的 Excel 工作簿ExcelQueryFactory
?
我可以使用下面的代码在没有密码保护的情况下读取 excel。
var excel = new ExcelQueryFactory();
excel.FileName = "path of excel file";
但是当excel受密码保护时,上面的代码会失败。
This useful site for connection strings claims it is impossible, but offers a workaround where the user is prompted for the password (via a GUI interaction) by the standard Excel COM object first. Maybe you can adapt this?
Alternatively, to do it programmatically, see MSDN here for the parameters to Workbooks.Open() and try the same technique: Open it via COM (and keep it open) then open it via LINQ-to-Excel.
(This is just a guess.)