我一直有一个问题,我无法编辑查询源的值。我尝试使用Excel.WorkbookConnection.ODBCConnection属性,但它总是抛出一个generica异常,即HRESTULT:0x800A03EC。我把SQL Source放在标题中的原因是因为如果你去数据源设置,我试图改变的源是在SQL Source下。仅供参考
以下是我目前的代码:
Excel.Application XLApp = new Excel.Application();
Excel.Workbook XLSourceWB = XLApp.Workbooks.Open(SourceFile);
Excel.WorkbookConnection connectionBS = XLSourceWB.Connections[2]; // The first connection that needs to be changed
System.Console.WriteLine(connectionBS.Name); //Returns the correct name
以下是我尝试自动执行的步骤的屏幕截图:
First go to the Query Tab, then click Edit
Then I need to change one of the parameters in the first source
任何输入都有帮助!
谢谢!