antvis / S2

⚡️ A practical visualization library for tabular analysis.
https://s2.antv.antgroup.com
MIT License
1.49k stars 197 forks source link

🐛Hidden data are present when exported in CSV, but not the hidden headers #2936

Closed fmo-dev closed 6 days ago

fmo-dev commented 1 month ago

🏷 Version

Package Version
@antv/s2 1.53.0
@antv/s2-react 1.45.0

Sheet Type

🖋 Description

If some columns have been hidden in a table and you use the copyData function to prepare a CSV to download from the spreadsheet object, it is generated with :

This results in an incorrect CSV, as there are more data columns than headers

⌨️ Code Snapshots

To export our table, we only use this code snipper

const data = copyData(spreadsheet, ";");
download(data, title)

🔗 Reproduce Link

https://codesandbox.io/p/sandbox/eager-pascal-rxkllp?file=%2Fsrc%2FApp.tsx%3A16%2C23

🤔 Steps to Reproduce

Hide one or many columns by clicking on a header and clicking on "Hide", then try to export the table by clicking on the button above

😊 Expected Behavior

No hidden data should be in the CSV

😅 Current Behavior

The hidden data are in the CSV, but not their header, so their corresponding header on the CSV is the wrong one, and this is the case for any column after that

For example if we have this table

Header1 Header2 Header3
Data1 Data2 Data3

If I hide the second column the table will looks like this

Header1 Header3
Data1 Data3

But if i use the function copyData it will returns this string

"Header1", "Header3",
"Data1", "Data2", "Data3"

Which is incorrect, because converting it to csv would give something similar to the table below

Header1 Header3
Data1 Data2 Data3

💻 System information

Environment Info
System Windows 11
Browser chrome: v130.0.6723.70
astragier commented 1 month ago

Hi! We have this bug in production, exporting tables while having some columns hidden result in an invalid CSV file. Can you please look at this bug??

lijinke666 commented 1 month ago

This was a known issue because there were a lot of copy/export issues, because have break changes in 1.x version, so we completely refactored this part of the logic in version 2.0, which is currently in private beta with a stable release expected next month.

If your project cannot be upgraded to 2.0, you will need to wait for a fix to be released later, or help us build together, submit bugfix patch PR.

lijinke666 commented 1 month ago

Version 2.0 is currently under construction and has only Chinese documentation.

github-actions[bot] commented 1 month ago

你好 @fmo-dev,该功能或缺陷已经在 2.0 next 版本 中支持或修复,next 版本目前处于内测中, 感谢你的支持与理解。

如有任何 2.0 版本 问题,请前往讨论区查看文档, 抢先试用:

yarn add @antv/s2@next  # pnpm add @antv/s2@next
yarn add @antv/s2-react@next  # pnpm add @antv/s2-react@next
yarn add @antv/s2-vue@next  # pnpm add @antv/s2-vue@next

Hello, @fmo-dev, This feature or flaw has been supported or fixed in 2.0 next version, next version is currently in private beta, thank you for your support and understanding.

Any 2.0 version issues, please go to discussion, or view docs, the first trial:

lijinke666 commented 1 month ago

ref: https://github.com/antvis/S2/issues/2885

astragier commented 1 month ago

This was a known issue because there were a lot of copy/export issues, because have break changes in 1.x version, so we completely refactored this part of the logic in version 2.0, which is currently in private beta with a stable release expected next month.

If your project cannot be upgraded to 2.0, you will need to wait for a fix to be released later, or help us build together, submit bugfix patch PR.

Ok we'll wait for the v2 but I hope it would be released next month as you expect. Indeed we are waiting for it since November 2023 when it was announced for end of the year 😅

lijinke666 commented 6 days ago

2.0 stable version is published. see https://s2.antv.antgroup.com/en/manual/migration-v2, other english documentation is WIP.

fmo-dev commented 6 days ago

Excellent news ! Do you have an idea of when the full english documentation will be available ?