English 中文(简体)
Excel中的命名区域在Excel中删除后仍会返回
原标题:Named range in Excel/VSTO being returned even after it s been deleted in Excel

我正在使用VSTO(由于客户端请求,在Visual Studio 2008上)在单个单元格上创建命名区域,然后将其保存到工作簿中,并在应用程序重新启动时读取。

如果我删除了excel中包含一个或多个命名范围的行,保存我的工作簿并重新启动excel,则该行中的命名范围仍将返回,这导致了我的问题。

为了给细胞命名,我做了一个简单的应用程序。选择名字=“随便”。为了在启动时让它们回来,我使用了应用程序。活动工作簿。名字。

有人能告诉我这是否是正确的行为吗?如果是这样,是否有任何方法可以通过C#excel互操作代码将范围过滤到当前可见的范围。

提前感谢。

最佳回答

是的,这是正确的行为,与VSTO无关。

删除有名称的区域时,该名称不会被删除。相反,它被替换为无效的引用:

Sheet1!#REF!  

检测此类名称的最简单方法是在读取RefersToRange属性时捕获异常。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签