Blazorise icon indicating copy to clipboard operation
Blazorise copied to clipboard

DataGrid export to Excel

Open stsrki opened this issue 11 months ago • 2 comments

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.

stsrki avatar Mar 27 '25 12:03 stsrki

"Export to Excel" can have two interpretations:

  • "Give me an .xlsx or .xls file"
  • "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.

tesar-tech avatar Mar 27 '25 20:03 tesar-tech

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)

stsrki avatar Apr 03 '25 09:04 stsrki