ExcelFile.InsertAndCopySheets Method
Overloads
- ExcelFile.InsertAndCopySheets(Int32, Int32, Int32)
- ExcelFile.InsertAndCopySheets(Int32[], Int32, ExcelFile)
- ExcelFile.InsertAndCopySheets(Int32, Int32, Int32, ExcelFile)
ExcelFile.InsertAndCopySheets(Int32, Int32, Int32)
Inserts and copies sheet "CopyFrom", SheetCount times before InsertBefore. To insert empty sheets, set CopyFrom = 0 (You might also call AddSheet).
Syntax
Namespace: FlexCel.Core
public void InsertAndCopySheets(Int32 copyFrom, Int32 insertBefore, Int32 aSheetCount)
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 InsertAndCopySheets(Int32[], Int32, ExcelFile) |
See also
ExcelFile.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 InsertAndCopySheets(Int32, Int32, Int32, ExcelFile) 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
Namespace: FlexCel.Core
public abstract 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
ExcelFile.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.Core
public abstract 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 InsertAndCopySheets(Int32[], Int32, ExcelFile) | |
sourceWorkbook | ExcelFile | Workbook from where the sheet will be copied from. Null to copy from the same file. |