excel - How will I open xlsx File in C#.NET? -


i want open xlsx file in c#.net, shows error .

but if file xls extension can open when file format xlsx shows error.

my code

oxl.workbooks.open(path, 0, false, 5, "", "", false,                //microsoft.office.interop.excel.xlplatform.xlwindows, "\t", false, false, 0, true, 1, 0) 

the exception is:

excel cannot open file 'new microsoft excel worksheet.xlsx' because file format or file extension not valid. verify file has not been corrupted , file extension matches format of file.

workbooks.open fail if have version of excel in machine can't read xlsx files (eg excel 2003).

if don't need office interop (so if need read , write files , not use excel functionalities) should take @ office open xml sdk (v2.5 .net 4.5 , v2.0 .net 3.5) @ the official download site.

you're able open excel file this:

spreadsheetdocument exceldocument = spreadsheetdocument.open(filename, false);  

and perform read , write operations.

to clear: office open xml sdk allows read- , write operations on excel (and other office xml) files, if require ms excel perform calculations or macros, not solve issue.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -