DataGrid export to Excel
https://blazorise.com/support/issues/273#comment_2360
We need to see how complex this might be. One thing I am certain of is that we don't want it as part of the DataGrid project. So, the only other way is to create a separate Blazorise project.
We can make it so that we can convert any Data to Excel, XML, CSV, or whatever we can think of.
Now, the only problem is how we connect this "project" with DataGrid. Because users can interact with DataGrid export through the context menu or through the Export button. Or anything else.
I'm open to proposals.
"Export to Excel" can have two interpretations:
- "Give me an
.xlsxor.xlsfile" - "Give me something I can open in Excel"
In most cases, users expect the second behavior when they click "Export to Excel".
This can be achieved relatively easily using CSV. Excel will automatically apply its own formatting once any (even minor) edits are made within the spreadsheet.
Proposal:
Start with CSV support. Build this functionality directly into Blazorise.DataGrid with extensibility in mind, so that it can be easily integrated with external projects later (Blazorise.DataGrid.Excel). This will allow us to plug in full Excel export functionality (e.g., generating .xlsx) later, while satisfying the "open in excel" majority now.
I think we can add Task<string> ExportToCsv() to DataGrid. We could also pass it an argument to define what to export.
Proposal:
enum DataGridExportInfo // find better name
{
CurrentView,
AllData,
}
then
Task<string> ExportToCsv(DataGridExportInfo info)