我如何识别空白单元格而不是使用c#在Excel中迭代它们 [英] How do I. Identify blank cells and not iterate through them in excel using c#

查看:149
本文介绍了我如何识别空白单元格而不是使用c#在Excel中迭代它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Excel在C#中添加格式化。我希望循环一个包含10,000多行的列。我的要求是如果细胞不是空的我必须做一些动作。在一列中,大多数100个单元格不为空。在整个专栏中循环需要花费大量的时间。



是否有任何方法在指定的范围内它消除了空白单元格并且只是迭代通过单元格不是空的。

这使我的表现提高了1000倍。



任何帮助表示赞赏。谢谢你的时间

I am Working on Excel Add in C# for Formatting.I want to loop in a column which consists of more than 10,000 rows. My requirement is if cells are not empty I have to do Some actions. In a column mostly 100 Cells are not empty. It is taking lot of time to loop in the whole column.

Is there any method that In a specified range it eliminates the blank cells and just iterates through the cells that are not empty.
this improves my performance 1000 times faster.

Any Help is appreciated. Thank you for your time

推荐答案

我想出来了



I figured it out

Excel.Range HeaderStrtRange = activeWorksheet.UsedRange.Columns[HeaderStartCol, System.Type.Missing];
               //only get the range that cells are not empty
           Excel.Range NotBlankRange = HeaderStrtRange.SpecialCells(Excel.XlCellType.xlCellTypeConstants);


这篇关于我如何识别空白单元格而不是使用c#在Excel中迭代它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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