如何使用C#在工作表中创建公式? [英] How to create formula in worksheet using c#?

查看:130
本文介绍了如何使用C#在工作表中创建公式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Epplus库用于excel工作表.
现在我有了工作表,在工作表1中有列名称,标记等,其中学生的< 35标记是,我用红色填充该单元格.

我的要求是

1)在worksheet2中,我想要worksheet1的总行数(学生总数)
我想将worksheet1的公式创建为worksheet2.
我用过这个公式,

worksheet2.Cells [10,5] .Formula ="SUM(""+ worksheet1.name +"''."+ worksheet1.Cells [4,6].地址+":"+ worksheet1.Cells [rowIndex,6] .地址+)"

但在工作表2的cell [10,5]处给出了ERR:508.

2)红细胞计数,例如.
学生姓名:-xyz
标记:-70,34,34
所以这里2个单元格将是红色.
所以我想在worksheet2中计数红色单元格.

I have used Epplus library for excel worksheet.
Now i have work sheets , i have columns name,marks,etc in worksheet1 ,in that which student has <35 marks , i fill that cell with red colour.

My requirements are

1) in worksheet2 , i want total rows of worksheet1 (total student )
i want to create formula of worksheet1 into worksheet2.
i have used this formula ,

worksheet2.Cells[10, 5].Formula = "SUM(''" + worksheet1.name+ "''." + worksheet1.Cells[4, 6].Address + ":" + worksheet1.Cells[rowIndex, 6].Address + ")"

but its gives ERR:508 in worksheet2 at cell[10,5].

2) count of red cell , eg.
student name :- xyz
marks :- 70 , 34 , 34
so here 2 cell will be in red color.
so i want count of red cell in worksheet2.

is there any solution reply as soon as possible.

推荐答案

Excel不支持颜色索引.您将必须使用"Countif"

Som
Excel doesn''t support color index. You will have to use "Countif"

Som


在这里,我逐行完成计数...
就像当我获得红色列时,在NEW COLUMN中我将写入0或ERROR,否则我将写入1或CORRECT.
然后在其他工作表中,我将计算发生正确位置的新列.
In this , i have done count row by row ...
Like when i gets red column , in NEW COLUMN i will write 0 or ERROR else i will write 1 or CORRECT.
then in other work sheet i will count NEW COLUMN''s where CORRECT is occurs.


在这里看看:如何根据Excel中的背景色对单元格进行计数和求和? [ ^ ]
提示:根据其颜色轻松计数或求和 [
Have a look here: Count The Number of Cells With Specific Cell Color By Using VBA[^]
How to count and sum cells based on background color in Excel?[^]
Tip: Easily COUNT or SUM cells based on their Color[^]


这篇关于如何使用C#在工作表中创建公式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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