我们如何找到“公式”使用c#使用spire xls的excel中的单元格? [英] How we can find "formula" cells in excel using spire xls using c#?

查看:944
本文介绍了我们如何找到“公式”使用c#使用spire xls的excel中的单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用c#使用spire xls在excel中找到公式单元格?



如何使用c#使用spire xls在excel中找到公式单元格?



我尝试了什么:



对象测试=表。行[0] [A1]。FormulaValue;

对象test1 = sheet.Rows [0] [A1]。公式;

对象test2 =表。行[0] [A1]。FormulaStringValue;



对象test3 = sheet.Rows [0] [A1]。FormulaR1C1;

object test14 = sheet.Rows [0] [A1]。FormulaErrorValue;

object test25 = sheet.Rows [0] [A1]。FormulaNumberValue;

How we can find "formula" cells in excel using spire xls using c#?

How we can find "formula" cells in excel using spire xls using c#?

What I have tried:

object test = sheet.Rows[0]["A1"].FormulaValue;
object test1 = sheet.Rows[0]["A1"].Formula;
object test2 = sheet.Rows[0]["A1"].FormulaStringValue;

object test3 = sheet.Rows[0]["A1"].FormulaR1C1;
object test14 = sheet.Rows[0]["A1"].FormulaErrorValue;
object test25 = sheet.Rows[0]["A1"].FormulaNumberValue;

推荐答案

语句 sheet.Rows [0] [A1]。公式; 返回变量(字符串的类型)。如果if以 = 开头,则表示该单元格包含公式。

请参阅: Range.Formula Property(Excel) [ ^ ]
A statement sheet.Rows[0]["A1"].Formula; returns variant (type of string). If if starts with "=", this means that cell contains formula.
See: Range.Formula Property (Excel)[^]


试试这段代码:

Try this code snippets:
foreach (CellRange cr in sheet.Range["A1:C4"].Cells)
{
    if(cr.HasFormula)
    {
       //..
    }
}


这篇关于我们如何找到“公式”使用c#使用spire xls的excel中的单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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