是否能把行头列头设置成可自选的模式?是否能将合并单元格的功能做成真正的将合并后的单元格的数值进行相加,而不是只是简单的显示 附图 #2797
annisFromchina
started this conversation in
Ideas
Replies: 1 comment
-
目前没开放配置, 感兴趣可以来个 PR, 比较简单. S2/packages/s2-react/src/components/switcher/dimension/index.tsx Lines 73 to 74 in 73b9b6c
合并单元格的能力比较弱, 人力有限, 不是后续迭代的重点, 目前是是参考的 Excel 的行为 保留左上角的文字, 如你需要求和, 可以参考 自定义合并单元格 的示例. class CustomMergedCell extends MergedCell {
// 重写绘制文本
getFieldValue() {
const [groupA] = this.spreadsheet.options.mergedCellsInfo || []
// 根据行列索引拿到合并之前单元格的值
const fieldValues = groupA.map(({rowIndex, colIndex}) => {
const meta = this.spreadsheet.facet.getCellMeta(rowIndex, colIndex)
return meta.fieldValue
})
const sum = fieldValues.reduce((a, b) => a + b, 0)
return sum
}
getTextPosition() {
const defaultTextPosition = super.getTextPosition()
const { x, y, width, height } = this.meta
console.log(this.meta)
return {
...defaultTextPosition,
// 重写文本位置
// x: 0,
// y: 0
}
}
} 如果后续反馈的人较多, 会考虑内置, 欢迎 PR. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
是否能把行头列头设置成可自选的模式?我自己P了一个简易图

是否能将合并单元格的功能做成真正的将合并后的单元格的数值进行相加,而不是只是简单的显示

Beta Was this translation helpful? Give feedback.
All reactions