Search Results for

    Show / Hide Table of Contents

    TExcelFile.InsertAndCopySheets Method

    Overloads

    • TExcelFile.InsertAndCopySheets(Integer, Integer, Integer)
    • TExcelFile.InsertAndCopySheets(Int32Array, Integer, TExcelFile)
    • TExcelFile.InsertAndCopySheets(Integer, Integer, Integer, TExcelFile)

    TExcelFile.InsertAndCopySheets(Integer, Integer, Integer)

    Inserts and copies sheet "CopyFrom", SheetCount times before InsertBefore. To insert empty sheets, set CopyFrom = 0 (You might also call AddSheet).

    Syntax

    Unit: FlexCel.Core

    procedure TExcelFile.InsertAndCopySheets(const copyFrom: Integer; const insertBefore: Integer; const aSheetCount: Integer); overload;

    Parameters

    <-> Parameter Type Description
    const copyFrom Integer The sheet index of the sheet we are copying from (1 based). Set it to 0 to insert Empty sheets.
    const insertBefore Integer The sheet before which we will insert (1 based). This might be SheetCount + 1, to insert at the end of the Workbook.
    const aSheetCount Integer How many times the sheet copyFrom will be copied. Note that this is **not** the last sheet to be copied, but how many times a single sheet will be copied instead. This means that for example InsertAndCopySheets(3, 1, 7) will insert 7 copies of sheet 3, not copy sheets 3 to 10. To copy multiple sheets see InsertAndCopySheets(Int32Array, Integer, TExcelFile)

    See also

    • TExcelFile

    TExcelFile.InsertAndCopySheets(Int32Array, Integer, TExcelFile)

    Inserts and copies all the sheets in the "CopyFrom" array, before InsertBefore into another workbook.

    Remarks

    When copying sheets from another file, the algorithm used is not so efficient as when copying from the same file.

    Use this version of the method only when copying from 2 different files. If you have for example a formula "=Sheet2!A1" in Sheet1, and another formula "=Sheet1!A1" in Sheet2, you need to use this method to copy them, as Copying them one by one (with the standard InsertAndCopySheets(Integer, Integer, Integer, TExcelFile) method) will return an error of formula references not found.

    You can also use ConvertFormulasToValues(Boolean) method to avoid formulas before copying between workbooks.

    Syntax

    Unit: FlexCel.Core

    procedure TExcelFile.InsertAndCopySheets(const copyFrom: TArray<Int32>; const insertBefore: Integer; const sourceWorkbook: TExcelFile); overload; virtual; abstract;

    Parameters

    <-> Parameter Type Description
    const copyFrom TArray<Int32> The sheet index of all the sheets we are copying from (1 based).
    const insertBefore Integer The sheet before which we will insert (1 based). This might be SheetCount+1, to insert at the end of the Workbook.
    const sourceWorkbook TExcelFile Workbook from where the sheet will be copied from. On this overloaded version it cannot be null.

    See also

    • TExcelFile

    TExcelFile.InsertAndCopySheets(Integer, Integer, Integer, TExcelFile)

    Inserts and copies sheet "CopyFrom", SheetCount times before InsertBefore. If sourceWorkbook is not null, sheets will be copied from another file. To insert empty sheets, set CopyFrom=0.

    Remarks

    When copying sheets from another file, the algorithm used is not so efficient as when copying from the same file. Whenever possible, don't copy from different files.

    Syntax

    Unit: FlexCel.Core

    procedure TExcelFile.InsertAndCopySheets(const copyFrom: Integer; const insertBefore: Integer; const aSheetCount: Integer; const sourceWorkbook: TExcelFile); overload; virtual; abstract;

    Parameters

    <-> Parameter Type Description
    const copyFrom Integer The sheet index of the sheet we are copying from (1 based). Set it to 0 to insert Empty sheets.
    const insertBefore Integer The sheet before which we will insert (1 based). This might be SheetCount+1, to insert at the end of the Workbook.
    const aSheetCount Integer How many times the sheet copyFrom will be copied. Note that this is **not** the last sheet to be copied, but how many times a single sheet will be copied instead. This means that for example InsertAndCopySheets(3, 1, 7) will insert 7 copies of sheet 3, not copy sheets 3 to 10. To copy multiple sheets see InsertAndCopySheets(Int32Array, Integer, TExcelFile)
    const sourceWorkbook TExcelFile Workbook from where the sheet will be copied from. Null to copy from the same file.

    See also

    • TExcelFile
    In This Article
    Back to top FlexCel Studio for VCL and FireMonkey v7.8.0
    © 2002 - 2020 tmssoftware.com