
x-spreadsheet表格冻结行/列功能
x-spreadsheet 提供了便捷的表头冻结功能,只需简单配置即可实现。 通过修改 options.view 配置项,即可启用滚动并指定滚动方向,从而固定表头。
配置方法
在 options.view 中,设置 scroll 为 true 并指定 scrollDirection。例如,要冻结表头并允许水平滚动,可以使用以下配置:
options.view = {
scroll: true,
scrollDirection: 'horizontal'
};
这将使表头在水平滚动时保持可见。
代码示例
将以上配置添加到您的 x-spreadsheet 初始化代码中:
// ...其他配置...
options.view = {
height: () => {
// ...高度计算逻辑...
},
width: () => {
// ...宽度计算逻辑...
},
scroll: true,
scrollDirection: 'horizontal' // 或 'vertical' 或 'both'
};
// ...其余代码...
通过调整 scrollDirection 为 'vertical' 或 'both',可以分别实现冻结左侧列和同时冻结表头和左侧列。 请根据您的需求选择合适的滚动方向。










