c# excel如何读取一列 没有限制的
代码如下:
Application xl = new Application();
Workbook wb = xl.Workbooks.Open(
netpath, 0, false, 5,
System.Reflection.Missing.Value, System.Reflection.Missing.Value, false,
System.Reflection.Missing.Value, System.Reflection.Missing.Value, true, false,
System.Reflection.Missing.Value, false, false, false);//Open the excel sheet
Sheets xlsheets = wb.Sheets; //Get the sheets from workbook
Worksheet excelWorksheet = (Worksheet)xlsheets[1]; //Select the first sheet
Range excelCellnumero = (Range)excelWorksheet.get_Range("A1:A50", Type.Missing); //Select a range of cells
Range excelCellnom = (Range)excelWorksheet.get_Range("B1:B50", Type.Missing);
System.Array valuesNumero = (System.Array)excelCellnumero.Cells.Value2; //Assign it to an array
System.Array valuesNom = (System.Array)excelCellnom.Cells.Value2;
xl.Quit();
可以看到现在是有限制的,我限制了读取的数量50个,我想要实现的是,假设数据是无限的在A列中,我要读取所有的这一列。
------解决方案--------------------
get_Range("A:A",Missing.Value)应该是吧