-
-
Notifications
You must be signed in to change notification settings - Fork 73
Issue 546 - Visible columns and data misalignment in export #592
Conversation
{col1: 1, col2: 2, col3: 3} | ||
{ col1: 1, col2: 2, col3: 'x', col4: 3 }, | ||
{ col1: 2, col2: 3, col3: 'x', col4: 4 }, | ||
{ col1: 1, col2: 2, col3: 'x', col4: 3 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add one unused (hidden) column to the dataframe
@@ -266,7 +270,7 @@ describe('export', () => { | |||
B2: {t: 'n', v: 2}, | |||
B3: {t: 'n', v: 3}, | |||
B4: {t: 'n', v: 2}, | |||
C1: {t: 's', v: 'col3'}, | |||
C1: {t: 's', v: 'col4'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed col3 for col4 above
The poster in #546 thought the correct behavior should be to show all columns, hidden or not. This PR results in the export correctly matching what's displayed, which sounds like a reasonable default, but perhaps to make everyone happy we need to support either option somehow? |
I think I misunderstood the poster's meaning. I still think the correct default behavior is to ignore hidden columns. (1) we already replicate the view’s content when it comes to sorting and filtering My suggestion is to expand on the
As we did elsewhere, leaving the basic usage simple but presenting a more complex prop for tweaking / advance usage. This should be simple enough to support, and could be folded in with the fix. |
Whether to include all or just visible columns doesn't really fit under the prop |
Fair enough. My attempts to minimize props were ill advised. |
- new export_columns prop - change export logic to export all columns if desired - additional typing - typo fix - changelog entry
const { columns, export_columns, export_format, virtual_data, export_headers, visibleColumns, merge_duplicate_headers } = props; | ||
const isFormatSupported = export_format === ExportFormat.Csv || export_format === ExportFormat.Xlsx; | ||
|
||
const exportedColumns = export_columns === ExportColumns.Visible ? visibleColumns : columns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use either visible columns or all columns depending on the prop setting
import { createWorkbook, createHeadings, createWorksheet } from './utils'; | ||
import getHeaderRows from 'dash-table/derived/header/headerRows'; | ||
|
||
interface IExportButtonProps { | ||
columns: Columns; | ||
export_format: string; | ||
export_columns: ExportColumns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated string usage to enums
|
||
interface IMergeObject { | ||
s: {r: number, c: number}; | ||
e: {r: number, c: number}; | ||
} | ||
|
||
export function transformMultDimArray(array: (string | string[])[], maxLength: number): string[][] { | ||
export function transformMultiDimArray(array: (string | string[])[], maxLength: number): string[][] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
{col2: 2, col3: 3} | ||
{col2: 2, col4: 3}, | ||
{col2: 3, col4: 4}, | ||
{col2: 2, col4: 3} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
col3 became col4 above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. Just the one comment about the changelog, then 💃
Fixes #546