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

Commit

Permalink
fix(bug): bug
Browse files Browse the repository at this point in the history
bug

fix #284, fix #296
  • Loading branch information
wpxp123456 committed Dec 8, 2020
1 parent 1d7ea8d commit b93ea6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 59 deletions.
4 changes: 3 additions & 1 deletion src/global/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export function setCellFormat(row, column, attr, value, options = {}) {
success
} = { ...options };
let targetSheetData = $.extend(true, [], Store.luckysheetfile[order].data);
let cellData = targetSheetData[row][column];
let cellData = targetSheetData[row][column] || {};

// 特殊格式
if (attr == 'ct' && (!value || !value.hasOwnProperty('fa') || !value.hasOwnProperty('t'))) {
Expand Down Expand Up @@ -363,6 +363,8 @@ export function setCellFormat(row, column, attr, value, options = {}) {
cellData[attr] = value;
}

targetSheetData[row][column] = cellData;

// refresh
jfrefreshgrid(targetSheetData, [{ "row": [row, row], "column": [column, column] }]);

Expand Down
61 changes: 3 additions & 58 deletions src/global/getRowlen.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ function rowlenByRange(d, r1, r2, cfg) {
}

let currentRowLen = Store.defaultrowlen;
// if(cfg_clone["rowlen"][r] != null){
// currentRowLen = cfg_clone["rowlen"][r];
// }

if(cfg_clone["customHeight"][r]==1){
continue;
Expand All @@ -39,7 +36,7 @@ function rowlenByRange(d, r1, r2, cfg) {
for(let c = 0; c < d[r].length; c++){
let cell = d[r][c];

if(cell == null){
if(cell == null || cell.mc != null){
continue;
}

Expand All @@ -53,63 +50,11 @@ function rowlenByRange(d, r1, r2, cfg) {
});

let computeRowlen = 0;
// console.log("rowlen", textInfo);

if(textInfo!=null){
computeRowlen = textInfo.textHeightAll+2;
}

// let fontset = luckysheetfontformat(cell);
// canvas.font = fontset;

// let value = getcellvalue(r, c, d).toString(); //单元格文本
// let measureText = getMeasureText(value, canvas);

// let textMetrics = measureText.width; //文本宽度
// let oneLineTextHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
// let spaceHeight = Math.ceil(oneLineTextHeight/3);
// let computeRowlen; //计算行高
// let word_space_height = oneLineTextHeight/3;
// if(cell.tb == "2"){
// //自动换行
// let cellWidth = colLocationByIndex(c)[1] - colLocationByIndex(c)[0] - 4; //单元格宽度

// if(textMetrics > cellWidth){
// let strArr = []; //文本截断数组
// strArr = getCellTextSplitArr(value, strArr, cellWidth, canvas);

// computeRowlen = (oneLineTextHeight+word_space_height) * strArr.length + spaceHeight;
// }
// else{
// computeRowlen = oneLineTextHeight + spaceHeight;
// }
// }
// else if(cell.tr != null){
// //单元格有旋转标示
// let tr = cell.tr;

// if(tr == "0"){
// //无旋转
// computeRowlen = oneLineTextHeight + spaceHeight;
// }
// else if(tr == "1" || tr == "2"){
// //向下倾斜(45 旋转)----向上倾斜(-45 旋转)
// computeRowlen = 0.707 * (textMetrics + oneLineTextHeight) + spaceHeight;
// }
// else if(tr == "3"){
// //竖排文字
// computeRowlen = value.length * oneLineTextHeight + spaceHeight;
// }
// else if(tr == "4" || tr == "5"){
// //向下90(90 旋转)----向上90(-90 旋转)
// computeRowlen = textMetrics + spaceHeight;
// }

// computeRowlen = Math.round(computeRowlen);
// }
// else{
// computeRowlen = oneLineTextHeight + spaceHeight;
// }

//比较计算高度和当前高度取最大高度
if(computeRowlen > currentRowLen){
currentRowLen = computeRowlen;
Expand All @@ -118,7 +63,7 @@ function rowlenByRange(d, r1, r2, cfg) {
}

currentRowLen = currentRowLen/Store.zoomRatio;
console.log(currentRowLen);

if(currentRowLen != Store.defaultrowlen){
cfg_clone["rowlen"][r] = currentRowLen;
}
Expand Down

0 comments on commit b93ea6b

Please sign in to comment.