我在一个winform应用程序中,它使用excel文件执行操作。
现在,我遇到了一个问题,需要在用过的行(编辑的行)之前获得第一个未使用的行。
我使用了下面的代码,它只给出了使用范围。
string fileName = Directory.GetCurrentDirectory()+"\\123.xlsx";
Excel.Application xlApp;
Excel.Workbook xlWorkbook;
xlApp = new Excel.Application();
xlWorkbook = xlApp.Workbooks.Open(fileName);
Excel._Worksheet xlWorksheet = (Excel._Worksheet)xlApp.Workbooks[1].Worksheets[1];
Excel.Range excelCell = xlWorksheet.UsedRange;
Object[,] values = (Object[,])excelCell.Value2;
int rows = values.GetLength(0);
int cols = values.GetLength(1);扩展程序:

从上面的例子中,我需要得到'3‘Cols和'10’行的结果。
现在是‘3’科尔斯和‘7’行。
如果有任何想法,请帮助我。谢谢。
发布于 2013-05-22 09:58:39
快速而肮脏--您可以使用以下内容:
int rows = excelCell.Rows.Count + excelCell.Row - 1;还有类似的栏目。
https://stackoverflow.com/questions/16688169
复制相似问题