c# - Slow Performance When Reading Excel -
i want read excel file in way slow. pattern should use read excel file faster. should try csv ?
i using following code:
applicationclass excelapp = excelapp = new applicationclass(); workbook myworkbook = excelapp.workbooks.open(@"c:\users\owner\desktop\employees.xlsx"); worksheet mysheet = (worksheet)myworkbook.sheets["sheet1"]; (int row = 1; row <= mysheet.usedrange.rows.count; row++) { (int col = 1; col <= mysheet.usedrange.columns.count; col++) { range datarange = (range)mysheet.cells[row, col]; console.write(string.format(datarange.value2.tostring() + " ")); } console.writeline(); } excelapp.quit();
the reason program slow because using excel open excel files. whenever doing file have com+ interop, extremely slow, have pass memory across 2 different processes.
microsoft has dropped support reading .xlsx
files using excel interop. released openxml library reason.
i suggest use wrapper library using openxml, since api pretty hairy. can check out how use correctly.
Comments
Post a Comment