经调研,当sheet.zoom()调整为0.8时,列宽变为49.6,此时Worksheet渲染的单元格宽度为50,所以出现此偏差。
您可以参考下方workaround解决此问题:- function setShapePos (shape, startRow, endRow, startColumn, endColumn, startRowOffset, startColumnOffset, endRowOffset, endColumnOffset) {
- shape.startRow(startRow);
- shape.endRow(endRow);
- shape.startColumn(startColumn);
- shape.endColumn(endColumn);
- shape.startRowOffset(startRowOffset);
- shape.startColumnOffset(startColumnOffset);
- shape.endRowOffset(endRowOffset);
- shape.endColumnOffset(endColumnOffset);
- }
- var shape1 = sheet.shapes.add('autoShape1', GC.Spread.Sheets.Shapes.AutoShapeType.rectangle);
- setShapePos(shape1, 1, 3, 0, 19, 0, 0, 20, 62);
- sheet.zoom(0.8);
- var shape2 = sheet.shapes.add('autoShape2', GC.Spread.Sheets.Shapes.AutoShapeType.rectangle);
- setShapePos(shape2, 5, 7, 0, 19, 0, 0, 20, 62);
复制代码
|