Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix: setCellValue API 可设置自定义的属性,不显式设置v, v 不会丢失
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry-f committed Dec 5, 2020
1 parent 9b693cc commit 6d45cf2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/global/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function setCellValue(row, column, value, options = {}) {
return tooltip.info("The order parameter is invalid.", "");
}

let data = $.extend(true, [], file.data);
let data = file.data;
if(data.length == 0){
data = sheetmanage.buildGridData(file);
}
Expand Down Expand Up @@ -147,6 +147,10 @@ export function setCellValue(row, column, value, options = {}) {
}
else if(value instanceof Object){
let curv = {};
let cell = data[row][column];
if(isRealNull(cell)){
cell = {};
}
if(value.f!=null && value.v==null){
curv.f = value.f;
if(value.ct!=null){
Expand All @@ -164,6 +168,9 @@ export function setCellValue(row, column, value, options = {}) {
if(value.v!=null){
curv.v = value.v;
}
else {
curv.v = cell.v;
}
if(value.m!=null){
curv.m = value.m;
}
Expand All @@ -175,7 +182,11 @@ export function setCellValue(row, column, value, options = {}) {
if(attr in formatList){
menuButton.updateFormatCell(data, attr, v, row, row, column, column);//change range format
}
else {
cell[attr] = v;
}
}
data[row][column] = cell;
}
else{
if(value.toString().substr(0,1)=="=" || value.toString().substr(0,5)=="<span"){
Expand Down

1 comment on commit 6d45cf2

@BerlinChan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.