Excel编程跟踪先例对于重复项不能正常工作 [英] Excel programming trace precedent not working properly for duplicates

查看:118
本文介绍了Excel编程跟踪先例对于重复项不能正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C ++中使用MS API  (Excel :: RangePtr :: ShowPrecedents)用于解析公式先例。对于类似 " = SUM(A1:A10)+ A1" [注意:A1重复] ShowPrecedents没有正确解析数据。我期待两个先例,而
解析它。它总是返回一个先例并且不解析 单A1。如果我在第二个先例中提到除A1之外的其他单元格,这项工作完全没问题。这是MS excel的bug还是限制?我们有解决方法吗?

I'm using MS API in C++  (Excel::RangePtr::ShowPrecedents) for parsing the formula precedents. For the formulas like "=SUM(A1:A10)+A1" [note: A1 is duplicated] ShowPrecedents are not parsing the data properly. I'm expecting TWO precedents while parsing it. It always returns one precedent and does not parse  single A1. This work perfectly fine if I'm refering to other cells apart from A1 in the second precedent. Is this MS excel bug or limitation? Do we have a work around fix for that?

此外,当我使用ShowPrecedents()时,它总是以与我们看到的顺序/顺序相同的顺序解析公式中的前提条件在公式字符串中?

Also, is it guaranteed that when I use ShowPrecedents() it always parses the precdents in the formula in the same order /sequence as we see in the formula string?

推荐答案

嗨Pervez,

Hi Pervez,

感谢您发帖,我们是很高兴为您提供帮助。

Thank you for posting and we are glad to help with you.

您能告诉我们您的Excel应用程序的版本是什么吗?还有一些代码片段?

Could you tell us what's the version of your Excel application? And some code snippet?

我通过C#在我的电脑上用Excel2010测试过,下面是我的代码片段,

I tested with Excel2010 on my computer via C#, below is my code snippet,


    private void DisplayPrecedents()
    {
      this.Range["A1", missing].Value2 = 1710;

      Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["C1", missing],
        "namedRange1");
      namedRange1.Value2 = "=SUM(A1:A10)+A1";
      namedRange1.ShowPrecedents(false);
      
    }


这篇关于Excel编程跟踪先例对于重复项不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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