How to create Excel spreadsheets from ASP.NET

I wanted to automate Excel Spreadsheets from ASP.NET, so that I could automatically create them from some data. I searched the internet and came up with this solution, that didn't work:

First you need to create Excel.dll. Using Excel 2003, the command is:

"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\tlbimp.exe" "c:\Program Files\Microsoft Office\OFFICE11\excel.exe" excel.dll

This creates a file called Excel.dll in the current directory. (It's a big file!)

Next, create a new webpage in C# mode, and put a "using Excel" line at the top with all the other "using" statements.

NO -- This is an out-of-date way for an older version of Excel. The real answer is more simple:

Go to "Solution Explorer", right click on your project and choose "Add Reference" then go to COM and find Excel 11. This adds Interop.Excel.dll to your bin directory.

3rd July 2006