ArrayList list = new ArrayList();
try{
//得到worksheet对象
Excel.Worksheet workSheet = ( Excel.Worksheet )workBook.Sheets[sheetIndex];//找到所需要的sheet
if( workSheet == null ) return null;
if( rowCount == 0 ) rowCount = workSheet.UsedRange.Rows.Count;//设置已用单元格的行数
if( columnCount == 0 ) columnCount = workSheet.UsedRange.Columns.Count;//设置已用单元格的列数
for( int i = 1; i <= rowCount; ++i )
for( int j = 1; j <= columnCount; ++j ){
SubstCell cellItem = new SubstCell();//创建单元格对象
cellItem.rowIndex = i;
cellItem.coluIndex = j;
Excel.Range range = (Excel.Range)workSheet.Cells[i, j];//取出单元格
if( range.Value2 != null )
if( IsDataFieldCell(cellItem.cellStr )) list.Add( cellItem );
}
}catch ( Exception Er ){
throw new Exception( "调用EXCEL程序出现错误!" + Er.Message );
}
finally{
if( workBook != null ) workBook.Close( false, Missing.Value, Missing.Value );
if( workBooks != null ) workBooks.Close();
if( excelApp != null ) excelApp.Quit();
}
return list;
}
}