Conversation
|
你好 @Alexzjt,非常感谢你的贡献. Hello, @Alexzjt, Thanks for your contribution. In order to make the code more robust, please add the corresponding unit tests, and update the docs if there are API changes. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求解决了一个关键的导出问题,即明细表中的序号列在导出数据时未能正确应用其配置的格式化函数。通过修改数据单元格复制逻辑,现在可以确保无论是在表格显示还是数据导出时,序号列的格式都保持一致,从而提升了数据导出的准确性和用户体验。 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3333 +/- ##
==========================================
+ Coverage 75.77% 78.67% +2.90%
==========================================
Files 257 224 -33
Lines 11994 12489 +495
Branches 2464 2836 +372
==========================================
+ Hits 9088 9826 +738
+ Misses 1398 956 -442
- Partials 1508 1707 +199 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
/**
* Issue #3332 最小复现:明细表导出不支持序号的格式化
* https://github.com/antvis/S2/issues/3332
*
* 问题:使用 asyncGetAllPlainData 导出明细表数据时,
* 序号列(SERIES_NUMBER_FIELD)的 meta formatter 不生效。
* 期望序号按 formatter 格式化导出(如 a, b, c),但实际导出的是原始数字。
*/
import {
SERIES_NUMBER_FIELD,
SpreadSheet,
asyncGetAllPlainData,
type S2DataConfig,
} from '@antv/s2';
import React, { useRef } from 'react';
import { createRoot } from 'react-dom/client';
import { SheetComponent, type SheetComponentOptions } from '../src';
const s2DataConfig: S2DataConfig = {
fields: {
columns: ['province', 'city', 'type', 'price'],
},
meta: [
{
field: SERIES_NUMBER_FIELD,
name: '序号',
formatter: (value) => {
// 将数字序号转换为字母:1->a, 2->b, 3->c ...
return String.fromCharCode(96 + Number(value));
},
},
],
data: [
{ province: '浙江', city: '杭州', type: '笔', price: 1 },
{ province: '浙江', city: '宁波', type: '纸', price: 2 },
{ province: '江苏', city: '南京', type: '笔', price: 5 },
{ province: '江苏', city: '苏州', type: '纸', price: 3 },
{ province: '广东', city: '广州', type: '笔', price: 4 },
],
};
const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
seriesNumber: {
enable: true,
},
};
function App() {
const s2Ref = useRef<SpreadSheet>(null);
const handleExport = async () => {
if (!s2Ref.current) {
return;
}
const csv = await asyncGetAllPlainData({
sheetInstance: s2Ref.current,
split: ',',
formatOptions: true,
});
console.log('导出结果:\n', csv);
};
return (
<div style={{ padding: 16 }}>
<h3>Issue #3332: 明细表导出不支持序号的格式化</h3>
<p>
表格中序号列显示为 a, b, c(formatter 生效),
但点击导出后控制台打印的序号仍为原始数字 1, 2, 3。
</p>
<button
onClick={handleExport}
style={{ marginBottom: 12, padding: '6px 16px', cursor: 'pointer' }}
>
导出数据(查看控制台)
</button>
<SheetComponent
sheetType="table"
dataCfg={s2DataConfig}
options={s2Options}
ref={s2Ref}
/>
</div>
);
}
createRoot(document.getElementById('root')!).render(<App />); |
|
Size Change: +24 B (0%) Total Size: 744 kB
ℹ️ View Unchanged
|
👀 PR includes
🐛 Bugfix
🔧 Chore
📝 Description
Issue #3332:明细表使用
asyncGetAllPlainData导出数据时,序号列(SERIES_NUMBER_FIELD)配置的meta.formatter不生效。表格渲染中 formatter 正常工作(显示 a, b, c),但导出结果仍为原始数字(1, 2, 3)。🖼️ Screenshot
🔍 Self-Check before the merge