My C# application takes alot of data from an excel file and process it then write it back on the file.
The problem is when loading the data from the Excel file, it takes some time (30 seconds for about 7000 field of Excel)
I want to make it faster, is there's any method to make it faster by significant amount of time?
The code I use to fetch the data is:
streamReader = new StreamReader(@"ExcelPath.txt");
string path = streamReader.ReadLine();
//An Excel Application ==(contains)==> [Many] Excel WorkBook ==(contains)==>[Many] Excel WorkSheets==(contains)==>[Many] Ranges
Microsoft.Office.Interop.Excel.Application excelapp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook myworkbook = excelapp.Workbooks.Open(path, 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true);
Microsoft.Office.Interop.Excel.Sheets myworksheets = myworkbook.Worksheets;
Microsoft.Office.Interop.Excel.Worksheet myworksheet =myworksheets.get_Item(1);
Microsoft.Office.Interop.Excel.Range range = myworksheet.UsedRange;
string[] data = new string[range.Rows.Count];
int start = 0;
for (start = 3; start < range.Rows.Count; start++)
{
Microsoft.Office.Interop.Excel.Range myrange = myworksheet.get_Range("O" + start.ToString(), System.Reflection.Missing.Value);
data[start] = myrange.Text;
}