Luckysheet
Luckysheet copied to clipboard
[BUG] 批注丢失问题
导入一个带批注的Excel文件,导入成功但是批注没有了; 在luckysheet编辑完带有批注,导出后批注消失;
同样遇到这个问题
把excel文件解析出来之后 手动循环把批注加进去 celldata.forEach((item) => { // console.log("item :>> ", item); let { r, c } = item; if (item.v.fc == "# 0, 0)") { item.v.fc = "#000"; } if (item.v.ct.s && item.v.ct.s.length !== 0) { let str = ""; item.v.ct.s.forEach((f) => { str += f.v; }); item.v.ct = { fa: "@", t: "s" }; item.v.v = str; r = r + 1; c = c + 1; const rcKey = i2s(c) + "" + r; if (mySheet[rcKey] && mySheet[rcKey].c) { const cText = mySheet[rcKey].c && mySheet[rcKey].c !== 0 && mySheet[rcKey].c[0].t; item.v.ps = { value: cText, isshow: false, }; } } });
导入一个带批注的Excel文件,导入成功但是批注没有了; 在luckysheet编辑完带有批注,导出后批注消失;
怎么解决这个问题呢
把excel文件解析出来之后 手动循环把批注加进去 celldata.forEach((item) => { // console.log("item :>> ", item); let { r, c } = item; if (item.v.fc == "# 0, 0)") { item.v.fc = "#000"; } if (item.v.ct.s && item.v.ct.s.length !== 0) { let str = ""; item.v.ct.s.forEach((f) => { str += f.v; }); item.v.ct = { fa: "@", t: "s" }; item.v.v = str; r = r + 1; c = c + 1; const rcKey = i2s(c) + "" + r; if (mySheet[rcKey] && mySheet[rcKey].c) { const cText = mySheet[rcKey].c && mySheet[rcKey].c !== 0 && mySheet[rcKey].c[0].t; item.v.ps = { value: cText, isshow: false, }; } } });
不错解决了,我们这样解决的:
luckySheets[0].celldata.forEach((item) => { // console.log("item :>> ", item); let { r, c } = item;
var cellRef = XLSX.utils.encode_cell({ r: r, c: c });
var cell = xlsxSheet[cellRef];
if (cell && cell.c) {
const cText = cell.c && cell.c !== 0 && cell.c[0].t;
item.v.ps = {
value: cText,
isshow: false
};
}
});
这里的xlsxSheet是指什么呀
这里的xlsxSheet是指什么呀
就是XLSX这个工具类读出来的Sheet对象,XLSX是SheetJs这个类库里的对象。
这里的xlsxSheet是指什么呀
就是XLSX这个类库读出来的Sheet对象
我是用luckyexecl读取的 没太看懂第一个回复里的这个mySheet是从那里来的
这里的xlsxSheet是指什么呀
就是XLSX这个类库读出来的Sheet对象
我是用luckyexecl读取的 没太看懂第一个回复里的这个mySheet是从那里来的
我也不知道他哪里来的,我是之前用SheetJs发现获取的Sheet是可以拿到批注信息的,就用它了。luckyExcel没有实现批注功能,拿不到信息。所以无法展示。要么有能力去修改luckyExcel源码增加读取批注的功能,要么用其它插件读取批注添加到luckySheet里面去,我们选择第二种方式。
mySheet
确实 看了下lucky excel源码 comment的读取实现还是空的,貌似也不打算维护了 感谢回复,我也用xlsx再解析了一遍处理了