Excel中是否有任何限制命名范围RefersTo? [英] Is there any limit in Excel Named range RefersTo ?

查看:99
本文介绍了Excel中是否有任何限制命名范围RefersTo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我现在正在使用Interop编写ac#Excel AddIn代码。

I am now writing a c# Excel AddIn Code using Interop.

我想创建一个按钮,将选定的单元格添加到现有范围。

I want to make a button to add the selected cells to the existing range.

下面的代码工作正常,但是当它超过一定数量的单元格时,会产生错误。

Below code works fine, but when it exceeds certain number of cells, it produces an error.

但是当我尝试使用Name manger在Excel中添加单元格时,我可以添加它。 

But when I try to add cells in the Excel using Name manger, I could add it. 

我认为长度有限制"引用关联"在代码中?有人知道这个吗?我可以添加超出限额的其他替代方式吗?

I assum there is a limit in the length "RefersTo" in the code? Does anybody know anything about this?? And any other alternative way I can add exceeding the limit?

我的代码如下:


      ;           //如果标记范围已存在,请将当前选择地址添加到其中

               ;&NBSP; for(var i = 1; i< = curWorkbook.Names.Count; i ++)

             ;&NBSP;&NBSP;&NBSP; {

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; if(curWorkbook.Names.Item(i,Type.Missing,Type.Missing).Name ==(" ADS_Mark" + markNum.ToString())))
     ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; {

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP; String [] eachRange = curWorkbook.Names.Item(i,Type.Missing,Type.Missing).RefersTo.Split(',');

                //If marked range already exists, add the current selection address to it
                for (var i = 1; i <= curWorkbook.Names.Count; i++)
                {
                    if (curWorkbook.Names.Item(i, Type.Missing, Type.Missing).Name == ("ADS_Mark" + markNum.ToString()))
                    {
                        String[] eachRange = curWorkbook.Names.Item(i, Type.Missing, Type.Missing).RefersTo.Split(',');

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; curWorkbook.Names.Item(i,Type.Missing,Type.Missing).RefersTo + =("," + mark1Address);

                            curWorkbook.Names.Item(i, Type.Missing, Type.Missing).RefersTo += ("," + mark1Address);

推荐答案

您好keondo.park

Hi keondo.park

它应该由您的分配方式而不是长度限制引起。

It should caused by your assign way but not the length limit.

要正确使用RefersTo,我们可以在文本字符串前加上一个=符号(这样Excel就会知道它应该是一个公式)。我们不应该使用+ =。

To use the RefersTo correctly, we can preface the text string with an = sign (so that Excel would know it was supposed to be a formula). We should not use +=.


这篇关于Excel中是否有任何限制命名范围RefersTo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆