C# - 从特定列获取最后一行 [英] C# - getting last row used from a particular column

查看:133
本文介绍了C# - 从特定列获取最后一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我来这里再次请求你的帮助。



我需要从特定列中获取最后一行 - 我只使用列的索引,而不是字母,我也使用不同颜色的格式单元格。



如何从特定列中获取最后一行的任何解决方案?



我尝试了什么:



  int  nInLastCol = xlWorkSheet.Cells.Find(  *,System.Reflection.Missing.Value, System.Reflection.Missing.Value,System.Reflection.Missing.Value,Excel.XlSearchOrder.xlByColumns,Excel.XlSearchDirection.xlPrevious, false ,System.Reflection.Missing。 Value,System.Reflection.Missing.Value).Row; 





它返回我的最后一列,最后一次使用该列中的行。



但是我需要一个特别的列而不是最后一个..

解决方案

你无法得到在没有迭代单元格范围的情况下在特定列中使用的最后一行(从[column] 1到 myWorksheet.UsedRange.Rows.Count )BACKWARDS直到找到最后一行一个值。





如果您只想要整体使用的行数,请使用 myWorksheet.UsedRange.Rows.Count

Hello everyone,

I'm here to ask for your help again.

I need to get the last used row from a specific column - I use only index of column, not letters for it and also i have them formatting using different colors for cells.

Any solution to how i could get the last used row from a specific column ??

What I have tried:

int nInLastCol = xlWorkSheet.Cells.Find("*", System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, Excel.XlSearchOrder.xlByColumns, Excel.XlSearchDirection.xlPrevious, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value).Row;



It returns me for the last column from my sheet, the last used row in that column.

But i need for a particularly column not the last..

解决方案

You can't get the last row used in a specific column without iterating the range of cells (from [column]1 to myWorksheet.UsedRange.Rows.Count) BACKWARDS until you find the last row with a value.


If you just want the number of rows used overall, use myWorksheet.UsedRange.Rows.Count


这篇关于C# - 从特定列获取最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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