How to check if an Excel Range is empty in C#

2020-04-05 08:39发布

I want to check if a range (cells in row * column) is empty using C#. I can traverse through cells, but any bettter and faster way ? Any method to get range from selected/active cell and number of rows and column ?

标签: c# excel vsto
1条回答
手持菜刀,她持情操
2楼-- · 2020-04-05 09:23

I suppose that Excel.WorksheetFunction.CountA works not only with sheets but with any Range argument:

Use CountA to count the number of cells that contain data in a range or array.

A value is any type of information, including error values and empty text (""). A value does not include empty cells.

If an argument is an array or reference, only values in that array or reference are used. Empty cells and text values in the array or reference are ignored.

查看更多
登录 后发表回答