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;
    }

    }

  • 相关阅读:
    vue+element-ui中的表单验证(电话等等)
    什么是 RegExp?
    C中的指针和字符串
    getchar与scanf区别
    回显程序
    Python基础之容器1----字符串和列表
    Python基础之语句2
    Python基础之语句1
    Python基础之数据基本运算
    python初识
  • 原文地址:https://www.cnblogs.com/yeyuqian/p/10750441.html
Copyright © 2011-2022 走看看