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.

open xml reading excel file


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -