-
-
Notifications
You must be signed in to change notification settings - Fork 73
Ability to export data as excel or csv #313
Comments
dash-table
- Ability to export data as excel or csv [Sponsored: Due April 1]
XLSX: One option that seems well supported https://github.com/SheetJS/js-xlsx -- also has a pro/commercial tier with unknown conditions. The community version is under Apache License; the implications of that might need to be checked out to be safe. CSV: Many options exist Including SheetJS above. As for other optional operations on the table, implement this in the most isolated manner possible to keep it well isolated from the table's implementation. Internally should be its own component. The feature's implementation must be purely front-end and will involve some JS magic to initiate what looks like a file download -- this is a known problem / been solved may times. The implementation should take into consideration the possibility of exporting the data as it is displayed in the table for future feature/improvement. Lazy-loading would be great but is not needed for this feature to be implemented. Will increase the table's bundle size significantly though. With a purely functional UI, this shouldn't take more than a few days to implement and test. |
Just dropping this here, the pro version of xlsx-js offers styling support No idea about licensing. |
@alinastarkov From our previous discussion, I'd say the CSV should export with the column id's and the XLSX should export with the column header names (multi-row / merged if required) The idea being that if the user does a CSV export I would expect him to be somewhat aware of the data structure or planning on further processing the data in system x-y-z. Exporting headers would potentially cause the CSV to have multiple header rows which is not processed by default (in pandas, can do headers=[0,1] for rows 0 and 1 being used as headers) -- also, exporting the headers might result in duplicated names. For XLSX, the user would arguably want to present or further process the data manually, not programmatically, and in this case the header names are more relevant. @alexcjohnson, additional insight? |
Similar to my comment in #318 (comment), the behaviour should be predictable and customizable by the Dash developer to start. The Dash developer will define the import/export UI for their App to serve a particular, structured workflow. So, to start:
In the future, we could enable the end-user to choose the behavior when they export as part of #316. However, that's not needed for the first pass. A possible API could look like:
The UI could be simple to start - display an "export" button at the bottom of the table, similar to pagination. To not lock us into this UI, we could require the users to specify the button location as a property so that when we implement #316 in the future, we could change the default. i.e.
|
With our
Good point for consistency. Although, I’m wondering if CSV and Excel exports should actually be consistent to start with as they might represent different use cases. Hence the differential behavior suggested above. @chriddyp could you delve deeper on the motivation behind this feature and usage scenarios?
If the table had merged header rows and we are currently capable of merging those rows, my feeling is that we should make the output (XLSX) match the source as best we can. I'd even envision us exporting the cell styling in the future. |
There are equally valid and common use cases for human readable CSVs and machine-readable, non-duplicated CSVs, so I vote for picking one of them, keeping it consistent with excel, and allowing it to be overridable. |
I’d say this is another case where it’ll depend on the structured workflow defined by the dash developer, and as such something we should make configurable. But to start, we can just expand it out so that it matches CSV. |
From talking with @Marc-Andre-Rivet yesterday it seems like the ability to choose Yes there are valid use-cases for human-readable CSV and machine-readable XLSX, but I'd argue the most common use cases, enough to warrant setting a filetype-dependent default for headers, are machine-readable CSV ( (Incidentally MAR and I discussed eventually even allowing merged headers with CSV, taking into account left/right alignment... not for v1 though, CSV/display would for now behave as CSV/names) |
Exporting Excel files may require a large 3rd party open source library. This library is too large to include in the default version of dash-table, so we will need to engineer dynamic JavaScript module loading as part of this requirement.
We will consider the UI for this feature in a separate issue (we need to design a UI needs encompasses all of the new features that we're adding).
The text was updated successfully, but these errors were encountered: