Search Results for

    Show / Hide Table of Contents

    XlsFile.InsertAndCopySheets Method

    Overloads

    • XlsFile.InsertAndCopySheets(Int32[], Int32, ExcelFile)
    • XlsFile.InsertAndCopySheets(Int32, Int32, Int32, ExcelFile)

    XlsFile.InsertAndCopySheets(Int32[], Int32, ExcelFile)

    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 ExcelFile.InsertAndCopySheets(Int32, Int32, Int32, ExcelFile) method) will return an error of formula references not found.

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

    Syntax

    Namespace: FlexCel.XlsAdapter

    public override void InsertAndCopySheets(Int32[] copyFrom, Int32 insertBefore, ExcelFile sourceWorkbook)

    Parameters

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

    See also

    • XlsFile

    XlsFile.InsertAndCopySheets(Int32, Int32, Int32, ExcelFile)

    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

    Namespace: FlexCel.XlsAdapter

    public override void InsertAndCopySheets(Int32 copyFrom, Int32 insertBefore, Int32 aSheetCount, ExcelFile sourceWorkbook)

    Parameters

    <-> Parameter Type Description
    copyFrom Int32 The sheet index of the sheet we are copying from (1 based). Set it to 0 to insert Empty sheets.
    insertBefore Int32 The sheet before which we will insert (1 based). This might be SheetCount+1, to insert at the end of the Workbook.
    aSheetCount Int32 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 ExcelFile.InsertAndCopySheets(Int32[], Int32, ExcelFile)
    sourceWorkbook ExcelFile Workbook from where the sheet will be copied from. Null to copy from the same file.

    See also

    • XlsFile
    In This Article
    Back to top FlexCel Studio for the .NET Framework v7.24.0.0
    © 2002 - 2025 tmssoftware.com