-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
导出报错,有其他导出方式吗?https://s2.antv.antgroup.com/examples/react-component/export/#export #3059
Comments
你好 @cy2zq: 提 Issue 须知如果是使用问题,不知道怎么用,移步 Discussions 讨论区 并提供 有效信息 进行 提问。 参与社区共建这是一个开源项目, 我们也有繁忙的业务要做, 是用自己的业余时间在维护, 为爱发电, 精力有限, 所以有时候 issue 响应速度不是那么及时, 如果你遇到了问题, 或者对 Issues 和 Discussions 列表的问题感兴趣, 可以直接认领并尝试修复 (贡献指南),帮助 S2 变得更好, 而不是一味的埋怨和催促, 我们不是甲方乙方的关系. |
补充参考--https://s2.antv.antgroup.com/api/components/export#1-%E5%AF%BC%E5%87%BA-csv 也报错 ![]() 代码如下--- <Button
|
官网的 React 导出组件示例有问题, 写法需要修改, 后续优化, 可以直接使用
你的报错是你使用的打包工具的问题, 和官网的报错没有任何关系, 通常是的打包工具太老了 解决方法参考 #3008 (comment)
这个函数找不到, 需要你自己排查下为什么, 检查下本地安装的版本 |
一 我试了下直接导出的@antv/s2的实例,调用方法是可以的,但下钻导出是csv的那个,我想咨询下要导出Excel格式的如xlsx,是不是不支持。 |
不支持, 只支持 csv 实例获取不到可以尝试保存为 state, 触发一下组件更新 function App() {
const [sheetInstance, setSheetInstance] = React.useState<SpreadSheet>();
const onMounted = (s2: SpreadSheet) => {
setSheetInstance(s2);
};
return (
<>
<Export sheetInstance={sheetInstance} />
<SheetComponent onMounted={onMounted}/>
</>
)
} |
可以了(实例获取不到可以尝试保存为 state, 触发一下组件更新 ),感谢;我咨询下你们有木有收费类似的企业级报表产品,支持复杂报表的导出Excel功能; |
参考官网示例,官网示例是报错(也无法使用),但是报错内容和我本地不同,
——我本地使用 版本
"@antv/s2": "^2.1.6",
"@antv/s2-react": "^2.1.5",
"@antv/s2-react-components": "^2.1.2",
只要使用import {
StrategyExport,
FrozenPanel,
ThemePanel,
} from "@antv/s2-react-components"; @antv/s2-react-components的组件就报错,
报错内容如下----
![image](https://private-user-images.githubusercontent.com/40606690/399601660-be5966a5-e2b8-45a4-8cb7-859c242f558d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNzE1NzIsIm5iZiI6MTczOTI3MTI3MiwicGF0aCI6Ii80MDYwNjY5MC8zOTk2MDE2NjAtYmU1OTY2YTUtZTJiOC00NWE0LThjYjctODU5YzI0MmY1NThkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDEwNTQzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE0ZDY5OGQwZmZiNDZiODhjNTRlMDlkNTY3NGU5ZTZiMTA3N2YwMWUyNDhjMDRiNGVhMWQ4Njc4ZjZhMWVkNTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Fpq_Ida82IrWC-Qq72Rm1eeRgqQsX5YsXZRflHNvnWk)
完整代码如下----
`
import { generatePalette, getPalette } from "@antv/s2";
import { SheetComponent } from "@antv/s2-react";
import {
StrategyExport,
FrozenPanel,
ThemePanel,
} from "@antv/s2-react-components";
import { ColorPicker, Card, Button } from "antd";
import { useState, useRef } from "react";
import "@antv/s2-react/dist/style.min.css";
import "@antv/s2-react-components/dist/s2-react-components.min.css";
import "./index.less";
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
const PALETTE_COLORS = [
{
limit: 10,
background: "#b8e1ff",
},
{
limit: 20,
background: "#b4d3fb",
},
{
limit: 30,
background: "#7daaff",
},
{
limit: 40,
background: "#5b8ff9",
},
{
limit: 50,
background: "#3d76dd",
},
{
limit: 60,
background: "#085ec0",
},
{
limit: 70,
background: "#085ec0cc",
},
{
limit: 80,
background: "#0047a5",
},
{
limit: 90,
background: "#00318a",
},
{
limit: 100,
background: "#001d70",
},
];
const getTargetColor = (value) => {
if (Number.isNaN(Number(value))) {
return PALETTE_COLORS[0].background;
}
return PALETTE_COLORS[Math.floor(Number(value) / 10)].background;
};
const PaletteLegend = () => {
return (
{PALETTE_COLORS.map((color) => (
<span
key={color.background}
className="palette-color"
style={{ background: color.background }}
/>
))}
);
};
let data1 = [
{
浙江二建: "xxx%",
indexType: "同比",
indexName: "应收账款占营收比例",
indexCfgId: xxx,
集团: null,
span: 0,
},
];
const TooltipContent = (props) => {
console.log(props, 184);
return
};
const App = (props) => {
const s2Ref = useRef(null);
let s1 = {
// width: 800,
// height: 530,
// hierarchyType: 'tree',
};
console.log(props, 357);
let s2 = {
fields: {
rows: ["indexName", "indexType"],
columns: [],
values: ["浙江二建", "集团"],
valueInCols: true,
},
meta: [
{
field: "indexName",
name: "指标名称",
},
{
field: "indexType",
name: "明细",
},
{
field: "classification",
name: "分类",
},
{
field: "company",
name: "公司",
},
{
field: "count",
name: "数值",
},
],
data: data1,
};
const [themeColor, setThemeColor] = useState("gray");
const [themeCfg, setThemeCfg] = useState({
name: "gray",
});
const updatePalette = (newThemeColor) => {
// 使用内置的 colorful 色板作为参考色板
const palette = getPalette(themeCfg.name);
// 使用参考色板 & 主题色值生成新色板
const newPalette = generatePalette({
...palette,
brandColor: newThemeColor,
});
};
return (
<div {...props}>
{//}
<ColorPicker
format={"rgb"}
value={themeColor}
onChange={(v) => {
setThemeColor(v);
updatePalette(v?.toRgbString());
}}
/>
{/<StrategyExport/}
{/* sheetInstance={s2Ref.current}/}
{/ onCopySuccess={(data) => {/}
{/ console.log("copy success:", data);/}
{/ }}/}
{/>/}
{/ 导出数据/}
{/*/}
<ThemePanel
title="主题配置"
disableCustomPrimaryColorPicker={false}
defaultCollapsed={false}
onChange={(options, theme) => {
setThemeCfg({
name: options.themeType,
theme,
});
s2Ref.current?.setOptions({
hierarchyType: options.hierarchyType,
});
s2Ref.current?.render(false);
console.log("onChange:", options, theme);
}}
onReset={(options, prevOptions, theme) => {
console.log("onReset:", options, prevOptions, theme);
}}
/>
<SheetComponent
adaptive={{ width: true, height: true }}
sheetType="pivot"
dataCfg={s2}
options={s1}
themeCfg={
themeCfg || {
name: "colorful", //'dark','gray'
}
}
ref={s2Ref}
/>
);
};
export default App;
`
Originally posted by @cy2zq in #3058
The text was updated successfully, but these errors were encountered: