MVC 2 Pass View to Controller to generate Excel File on-the-fly
Is there a way to pass data from a View t开发者_高级运维o a Controller so that I can get the data and create a .xls file on the fly?
Any help or thoughts are greatly appreciated.
Greg
The easiest way is to create a CSV file, which can be opened directly by Excel.
Alternatively, you can use COM Interop to generate the Excel files.
The data is passed from the view to the controller method in the usual way. If you need help getting a collection of rows from the view, have a look here.
The data is provided to the user by returning a FileResult.
ASP.NET MVC Tip #2 - Create a custom Action Result that returns Microsoft Excel Documents
How about this.
精彩评论