How to limit my row or column that don't have a value in Excel file?
How to limit my row or column that don't have a value in Excel file?
I want to limit my row or column. See the picture, the highlighted part is the range.

below is my code.
Excel.Range range = _currentSheet.UsedRange;
for (rCnt = 1; rCnt <= rw; rCnt++)
for (cCnt = 1; cCnt <= cl /*Limit Column Count*/; cCnt++)
//str = (string)(range.Cells[rCnt, cCnt] as Range).Value2;
str = Convert.ToString((range.Cells[rCnt, cCnt] as Range).Value2);
MessageBox.Show(str.ToString());
its OK :D hope you can help me
– Qwerty
Sep 14 '18 at 2:34
Please pick a language. Not both vb and C#
– Mary
Sep 14 '18 at 4:23
1 Answer
1
//get the number of rows with data
rw = _currentSheet.UsedRange.Rows.Count;
//get the number of columns with data
cl = _currentSheet.UsedRange.Columns.Count;
I used this code then it work!
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
look at the picture
– Qwerty
Sep 14 '18 at 2:11