您好,我这边是可以的,我直接用addSpan添加了2*2的合并单元格,我把代码贴出来您参考一下,
如果还是不行,您提供一个能重现问题的,最简单的Demo,我这边排查一下问题。
- $(document).ready(function () {
- var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
- var spread1 = new GC.Spread.Sheets.Workbook(document.getElementById("ss1"));
- var activeSheet = spread.getActiveSheet();
- activeSheet.setRowHeight(0, 80)
- activeSheet.setColumnWidth(0, 200)
- var myCellType = new MyCellType();
- activeSheet.getCell(0,0).cellType(myCellType).value("Hello Wordl1, Hello World2")
- activeSheet.addSpan(0,0,2,2);
- $("#fromtoJsonBtn").click(function() {
- // ToJson
- var spread1 = $("#ss").data("workbook");
- var jsonStr = JSON.stringify(spread1.toJSON());
- // FromJson
- var spread2 = $("#ss1").data("workbook");
- spread2.fromJSON(JSON.parse(jsonStr));
- });
- });
- function MyCellType() {
- GC.Spread.Sheets.CellTypes.Base.apply(this, arguments);
- this.typeName = "MyCellType";
- }
- MyCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
- MyCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
- //Paints a cell on the canvas.
- if (!ctx) {
- return;
- }
- ctx.save();
- ctx.beginPath();
- ctx.moveTo(x,y);
- ctx.lineTo(x+w,y+h);
- ctx.stroke();
- ctx.font = style.font;
- var text = value ? value.split(",") : ["",""];
- ctx.fillText(text[0].trim() ,x + w *7/8, y + h/3);
- ctx.fillText(text[1].trim(),x + w /2, y + h*3/4);
- ctx.restore();
- };
复制代码 |