1金币
本帖最后由 sunqinhui 于 2024-11-25 11:51 编辑
spreadjs v17.1.9 数据源字段保留了中文 但是数据没了
这里是fetch在获取文件 spread.open() 中的回调函数中刷新字段
fetch(CONTENT_PATH, { mode: 'cors' }).then(res => res.blob()).then(blob => {
spread.open(blob, function () {
// 刷新字段
for (const t in spread.dataManager().tables) {
let schemaColumns =
spread.dataManager().tables[t].options.schema.columns;
let columns = spread.dataManager().tables[t].columns;
let map = {};
for (const key in schemaColumns) {
if (schemaColumns[key].dataName) {
map[schemaColumns[key].dataName] = key;
}
}
spread.dataManager().tables[t].columns = null;
spread.dataManager().tables[t].options.schema.columns = null;
spread
.dataManager()
.tables[t].fetch(true)
.then(() => {
let option = spread.dataManager().tables[t].options;
for (const key in map) {
let ifSet = false;
if (spread.dataManager().tables[t].columns[key]) {
ifSet = true;
}
delete option.schema.columns[key];
delete spread.dataManager().tables[t].columns[key];
if (ifSet) {
option.schema.columns[map[key]] = schemaColumns[map[key]];
spread.dataManager().tables[t].columns[map[key]] =
columns[map[key]];
}
}
designer.refresh();
});
}
});
});
|
|