这是一个问题描述.
条件:一般的想法是从MS Excel文件中读取大量实数,并将它们放入inro ArrayList中进行进一步处理.excel工作簿只有一个工作表.所有数字都是实数,它们存储在一列中.我逐行读取这些数字并将它们放入ArrayList中.
问题:这个过程花费了太多时间.程序花费大约2分钟来填充具有10000个元素的ArrayList.这是我的代码.我需要你的建议让它更快.但是文件的结构无法修改.它只能修改代码.请帮助我加快速度.
// Method GetExcelData opens 1 excel file, reads data row by row and adds
// it into the array of source Data Values (sourceDataValues in our case).
private void GetExcelData(string fullPath, ArrayList arrForValues)
{
Excel.Application excelapp = new Excel.Application();
excelapp.Visible = false;
// to avoid appearing of Excel window on the screen
Excel.Workbook excelappworkbook = excelapp.Workbooks.Open(
fullPath,
Type.Missing, Type.Missing, true, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
Excel.Worksheet excelworksheet = (Excel.Worksheet)excelappworkbook.Worksheets.get_Item(1); …Run Code Online (Sandbox Code Playgroud)