View Full Version : [CLOSED] Export data to excel in EXT NET MVC

Mar 12, 2020, 4:42 AM
Hello, I am new here and I have a question, I would like to know if you can export the information from a GridPanel to an Excel in Ext.Net MVC, I have seen that it is possible for WebForms but I do not see examples for MVC.

Mar 12, 2020, 3:39 PM
Hello @pvera!

The MS-Excel export you may have seen in WebForms (where did you see that, do you have a link? was it in our examples explorer?) uses third-party libraries/software to do so. It simply passes back the data of the grid panel to the third-party software to generate the document in proprietary format.

Two ways I know about doing that is by using the XSL Transformation (xslt) (https://www.w3schools.com/xml/xsl_intro.asp), and the Microsoft Office Interop (https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/interop/how-to-access-office-onterop-objects).

This means the technology is all WebForms, MVC and Ext.NET agnostic. You get the data to code behind and process it into an MS-Excel file. If this sounds too complicated, you may be able to work with just .csv as well.

Furthermore, you should be able to, given you found an example using what you need in WebForms, to rather easily be able to port that into MVC scope.

Whenever possible, if you mention something you seen in one example among our examples explorer, please share also a link to said example for clarity; it may unveil information that would help us further help you.

Hope this helps!

Mar 12, 2020, 4:10 PM
Thanks for reply Fabricio,

The example link is as follows https://examples5.ext.net/#/GridPanel/Miscellaneous/Export_Data_Ajax/.

And if I manage to do it in MVC with XSLT but now I would like to know if it is possible and how to customize the file.

Mar 12, 2020, 5:01 PM
Hello again, @pvera!

Some time back, while working with XSLT, I had issues having it output files in the new Excel format (XLSX), and I didn't really work a lot with the technology, but it felt pretty limited as to how much it could express in terms of the output XLS file.

But in the other hand, for what I know about the Office interop model, you can do pretty much anything you could in the graphical interface via the C# one. In fact, you can not only output XLS files from it, but also author powerpoint presentations, word documents... But there's a lot of reflection (or at least was when I worked with that) involved. It may be as powerful as complex in algorithms.

We can't have examples on office interop in our Examples Explorers because it requires licenses to run. I'm afraid I'm not certain which licenses you need, that's a matter for the company owning the product -- Microsoft.

Again, these are third party technologies and are not directly involved with Ext.NET. The most you would need from this is, say, if you want to export a grid matching displayed columns and column orders, these could be passed by Ext.NET to code behind (you may need to pass them as extraParameters). In other words, the interface, the outline from the Ext.NET view you may want to use in your output file. As for the output per se, it is all due with either XSLT and MS-Office Interop.

There may be other technologies out there for the same objective (output XLS or XLSX files) that could better fit your needs; it is just outside our scope and we simply are not aware of them.

Disclaimer: The above experience and information about XSLT and MS-Office Interop is mine, Fabricio's. In no way Ext.NET or Object.NET is endorsing either technology as their "official". In fact, what technologies you use to generate file reports is not covered by Ext.NET, you're free to use any tool you rightfully hold rights for.

In short, and objectively responding your inquire: It should be possible to customize the file, but it is up to the third-party tool you're using, the extent of customization you can attain.

Hope this helps!

Mar 12, 2020, 9:18 PM
Thanks for your answer.

Mar 13, 2020, 3:39 AM
Hope it helped!

Assuming it did, I'm marking this thread as closed. Please let us know otherwise.