c# - 如何使用C#获取Excel中当前打开的文档?

标签 c# .net excel interop automation

我只需要在当前打开的 Microsoft Excel 实例中获取当前打开文档的列表。

但是我不懂Excel术语,不知道这些文档是叫工作簿,还是工作表,还是窗口等等。

任何想法

最佳答案

找到了 (link) .

//Excel Application Object
Microsoft.Office.Interop.Excel.Application oExcelApp;

this.Activate ( );

//Get reference to Excel.Application from the ROT.
oExcelApp = ( Microsoft.Office.Interop.Excel.Application ) System.Runtime.InteropServices.Marshal.GetActiveObject ( "Excel.Application" );

//Display the name of the object.
MessageBox.Show ( oExcelApp.ActiveWorkbook.FullName );

//Release the reference.
oExcelApp = null;

关于c# - 如何使用C#获取Excel中当前打开的文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2449387/

相关文章:

c# - 在浏览器中打开 URL 并更改应用程序 View - Android Xamarin

c# - C# 中 WriteableBitmap 和 Bitmap 的区别

c# - 当我将解决方案移动到另一个目录时,为什么在使用 "Database already exists"时得到 "AttachDbFileName"?

c# - 序列化相似的类

c# - AutoResetEvent 重置方法

c# - 使用新的 .NET SDK Azure.Messaging.EventHubs 通过 EventProcessorClient 进行检查点

c# - 使用 DataContractSerializer 序列化时缺少 XML 的末尾

python - 如何编写 for 循环将 Excel 文件读入 Python

excel - VBAvalues 从多维数组到特定范围

php - 使用 phpspreadsheet 库将数据从数组写入工作表