zoukankan      html  css  js  c++  java
  • spreadjs 复制单元格样式

    /**
    * @param {起始行} a
    * @param {起始列} b
    * @param {复制到行} c
    * @param {复制到列} d
    * @param {复制多少行} e
    * @param {复制多少列} f
    * @param {添加行循环次数} g
    * @param {要复制的sheet页行} copyA
    * @param {要复制的sheet页列} copyB
    * @param {要复制标签页} copySheet
    * @param {复制到标签页} toSheet
    * @param {spread} spread
    */

    function copysty(a, b, c, d, e, f, g,copyA,copyB,copySheet,toSheet,spread)
    {
    var sheetto = spread.getSheet(toSheet);
    var sheetcopy = spread.getSheet(copySheet);
    for (var i = 0; i < g; i++) {
    sheetto.addRows(c,e);
    var selectionRange = sheetcopy.getRange(copyA,copyB,e,f);
    fromRange = selectionRange;
    fromSheet = sheetcopy;
    sheetto.isPaintSuspended(true);
    var toRange = sheetto.getRange(c,d,e,f);
    //toRange biger than fromRange
    if (fromRange.rowCount > toRange.rowCount) {
    toRange.rowCount = fromRange.rowCount;
    }
    if (fromRange.colCount > toRange.colCount) {
    toRange.colCount = fromRange.colCount;
    }
    //toRange must in Sheet
    if (toRange.row + toRange.rowCount > sheetto.getRowCount()){
    toRange.rowCount = sheetto.getRowCount() - toRange.row;
    }
    if (toRange.col + toRange.colCount > sheetto.getColumnCount()) {
    toRange.colCount = sheetto.getColumnCount() - toRange.col;
    }
    var rowStep = fromRange.rowCount, colStep = fromRange.colCount;
    var endRow = toRange.row + toRange.rowCount - 1, endCol = toRange.col + toRange.colCount - 1;
    // if toRange bigger than fromRange, repeat paint
    for (var startRow = toRange.row; startRow <= endRow; startRow = startRow + rowStep) {
    for (var startCol = toRange.col; startCol <= endCol; startCol = startCol + colStep) {

    var rowCount = startRow + rowStep > endRow + 1 ? endRow - startRow + 1 : rowStep;
    var colCount = startCol + colStep > endCol + 1 ? endCol - startCol + 1 : colStep;
    // sheet.copyTo(fromRange.row,fromRange.col, startRow, startCol, rowCount, colCount,GC.Spread.Sheets.CopyToOptions.style | GC.Spread.Sheets.CopyToOptions.span);
    var fromRanges = new GC.Spread.Sheets.Range(fromRange.row, fromRange.col, rowCount, colCount);
    var pastedRange = new GC.Spread.Sheets.Range(startRow, startCol, rowCount, colCount);
    spread.commandManager().execute({
    cmd: "clipboardPaste",
    sheetName: sheetto.name(),
    fromSheet: fromSheet,
    fromRanges: [fromRanges],
    pastedRanges: [pastedRange],
    isCutting: false,
    clipboardText: "",
    pasteOption: GC.Spread.Sheets.ClipboardPasteOptions.all
    });
    }
    }
    c += e;
    }

    }

  • 相关阅读:
    小白学 Python 数据分析(21):pyecharts 好玩的图表(系列终篇)
    小白学 Python 数据分析(20):pyecharts 概述
    小白学 Python 数据分析(19):Matplotlib(四)常用图表(下)
    小白学 Python 数据分析(18):Matplotlib(三)常用图表(上)
    在 ASP.NET Core 程序启动前运行你的代码
    在 ASP.NET Core 项目中使用 MediatR 实现中介者模式
    在 ASP.NET Core 项目中使用 AutoMapper 进行实体映射
    [Vue 牛刀小试]:第十七章
    或许是你应该了解的一些 ASP.NET Core Web API 使用小技巧
    [Vue 牛刀小试]:第十六章
  • 原文地址:https://www.cnblogs.com/yeyuqian/p/10750441.html
Copyright © 2011-2022 走看看