|
@@ -497,6 +497,7 @@ var setStyleAndValue = function (cellArr, worksheet) {
|
|
|
return radio;
|
|
|
};*/
|
|
|
var getImagePosition = function (num, arr) {
|
|
|
+ let returnObj = null;
|
|
|
for (let i = 0; i < arr.length; i++) {
|
|
|
const item = arr[i]
|
|
|
if (num < item) {
|
|
@@ -506,9 +507,19 @@ var getImagePosition = function (num, arr) {
|
|
|
const rowOrCol = i > 0 ? (num - arr[i - 1]) / (arr[i] - arr[i - 1]) + i:num/item
|
|
|
const native = Math.floor(rowOrCol)
|
|
|
const nativeOff = parseInt(new Big(rowOrCol).minus(native).toNumber() * cellInEmu)
|
|
|
- return { rowOrCol, native, nativeOff }
|
|
|
+ returnObj = { rowOrCol, native, nativeOff }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if(returnObj == undefined || returnObj == null){
|
|
|
+ const currentV = arr[arr.length-1]
|
|
|
+ const frontV = arr[arr.length-2]
|
|
|
+ const cell = currentV - frontV
|
|
|
+ arr.push(currentV + cell)
|
|
|
+ returnObj = getImagePosition(num,arr)
|
|
|
+ }
|
|
|
+ return returnObj;
|
|
|
}
|
|
|
/**
|
|
|
* 设置图片
|
|
@@ -581,11 +592,13 @@ var setImages = function (table, worksheet, workbook) {
|
|
|
const col_ed = getImagePosition(w_ed, visibledatacolumn);
|
|
|
const row_ed = getImagePosition(h_ed, visibledatarow);
|
|
|
// 需要设置nativeCol,nativeColOff,nativeRow,nativeRowOff,可以省略col,row
|
|
|
- worksheet.addImage(imageId, {
|
|
|
- tl: { nativeCol: col_st.native, nativeColOff: col_st.nativeOff, nativeRow: row_st.native, nativeRowOff: row_st.nativeOff },
|
|
|
- br: { nativeCol: col_ed.native, nativeColOff: col_ed.nativeOff, nativeRow: row_ed.native, nativeRowOff: row_ed.nativeOff },
|
|
|
- editAs: 'oneCell',
|
|
|
- });
|
|
|
+ if(row_ed != undefined && col_ed != undefined){
|
|
|
+ worksheet.addImage(imageId, {
|
|
|
+ tl: { nativeCol: col_st.native, nativeColOff: col_st.nativeOff, nativeRow: row_st.native, nativeRowOff: row_st.nativeOff },
|
|
|
+ br: { nativeCol: col_ed.native, nativeColOff: col_ed.nativeOff, nativeRow: row_ed.native, nativeRowOff: row_ed.nativeOff },
|
|
|
+ editAs: 'oneCell',
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
|