前言
文档上好像并没有写如何设置单元格样式 浪费了一点时间摸索了半天摸到一个方式 特此记录 一是自己以后不要在掉坑 二是也节省看到此篇文档的工具人的时间 正确多干点活 让你们老板早日再换辆车
//定义一个样式对象
let style = {
bgcolor: '#f4f5f8',
textwrap: true,
color: '#900b09',
border: {
top: ['thin', '#0366d6'],
bottom: ['thin', '#0366d6'],
right: ['thin', '#0366d6'],
left: ['thin', '#0366d6'],
},
};
//添加样式到这个东西(sheetInstance为你创建的 x-data-spreadsheet 实例)
sheetInstance.data.addStyle(style);
//当前sheet的名字
const target_sheet_name = `sheet1`;
//找到对应的sheet对象
const target_data = sheetInstance.datas.find(it => it.name === target_sheet_name);
//设置行元素( ri ci 为单元格坐标)
target_data.rows.setCell(ri, ci, {style: 0}, 'format');
效果如下:
【写这票文章时掘金传图报跨域错误】 传不上来