5

I'm working to create and read MS Excel file in asp.net web application. I'm not sure that it requires to install Microsoft Excel on server or not.

I don't want to install any licensed product on the server like MS office etc.

Please let me know how i can implement this functionality without installing MS Excel on the server or it is necessary to install MS excel on server?

Thanks

Saverio Terracciano
  • 3,885
  • 1
  • 30
  • 42
Code Rider
  • 2,003
  • 5
  • 32
  • 50
  • this is very similar to the question below: http://stackoverflow.com/questions/9155642/how-to-read-an-excel-file-in-c-sharp-without-using-microsoft-office-interop-exce – Sam Vanhoutte Apr 16 '14 at 17:36
  • Also take a look at office interop http://msdn.microsoft.com/de-de/library/dd264733.aspx – CSharpie Apr 16 '14 at 17:53

2 Answers2

8

It depends on what you're doing, but more than likely, all you need is the Microsoft Access Database Engine.

This download will install a set of components that facilitate the transfer of data between existing Microsoft Office files such as Microsoft Office Access 2010 (*.mdb and .accdb) files and Microsoft Office Excel 2010 (.xls, *.xlsx, and *.xlsb) files to other data sources such as Microsoft SQL Server. Connectivity to existing text files is also supported. ODBC and OLEDB drivers are installed for application developers to use in developing their applications with connectivity to Office file formats.

Edit, in response to

I just want to read and write MS excel files but i don't want to install anything on the server.

You can try EPPlus, which seems to solve your problem; though I've never tried it.

EPPlus is a .net library that reads and writes Excel 2007/2010 files using the Open Office Xml format (xlsx).

Giovanni Galbo
  • 12,963
  • 13
  • 59
  • 78
1

No it isn't necessary to install a full version of Microsoft Office. You can just use ODBC or OLE to open the files, provided you just need to do simple operations like read rows in worksheets (as if they were tables).

Use http://www.connectionstrings.com/ to look up the various .NET ways of accessing Excel using ODBC and OLE.

Effectively you need to treat the .xls and .xslx files as if you were querying an SQL database.

Martin Costello
  • 9,672
  • 5
  • 60
  • 72
  • Just bog-standard SQL querying will do it, you just need to use the appropriate connection string. The other gotcha is that "table" names in Excel start with the `$` character. – Martin Costello Apr 16 '14 at 17:46