Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

XL.CopySheet

Copies a sheet to another book.

Component Version macOS Windows Linux Server iOS SDK
XL 6.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "XL.CopySheet"; bookRef1; bookRef2; sheetIndex { ; Options } )   More

Parameters

Parameter Description Example Flags
bookRef1 The reference to the source workbook. Please use XL.LoadBook to load a file. $ref
bookRef2 The reference to the destination workbook. Please use XL.LoadBook to load a file. $ref
sheetIndex The index of the sheet.
This number ranges from 0 to XL.Book.SheetCount-1.
0
Options Which items to skip when copying content. "" Optional

Result

Returns OK or error.

Description

Copies a sheet to another book.
This copies most properties and all cells.
If something is missing, please let us know.

OptionDescription.
SkipPicturesDon't copy pictures.
SkipMergesDon't copy merged cells.
SkipNamedRangesDon't copy named ranges.
SkipPrintAreaDon't copy print area.
SkipPrintRepeatDon't copy print repeat
SkipPrintFitDon't copy print fit.
SkipHorPageBreakDon't copy horizontal page breaks.
SkipCommentsDon't copy cell comments.
SkipFormatsDon't copy formats.
SkipRowHiddenDon't copy hidden rows.
SkipColHiddenDon't copy hidden columns.

Examples

Merge two Excel documents:

# Load 2 existing books
Set Variable [ $$Book_WKPI ; Value: MBS( "XL.LoadBook"; SheetCopy::XLSX1; 0 ) ]
Set Variable [ $$Book_MKPI ; Value: MBS( "XL.LoadBook"; SheetCopy::XLSX2; 0 ) ]
#
# Make sure sheets have names
Set Variable [ $mbs ; Value: MBS( "XL.Sheet.SetName"; $$Book_MKPI; 0; "Monthly" ) ]
Set Variable [ $mbs ; Value: MBS( "XL.Sheet.SetName"; $$Book_WKPI; 0; "Weekly" ) ]
#
# copy one to other
Set Variable [ $mbs ; Value: MBS( "XL.CopySheet"; $$Book_MKPI; $$Book_WKPI; 0 ) ]
#
# save result in container
Set Variable [ $fileName ; Value: Substitute("Statistic__" & Substitute (Get(CurrentDate);".";"-") & "_" & Substitute(Get(CurrentTime); ":"; "-") & ".xlsx"; " Uhr"; "") ]
Set Field [ SheetCopy::ResultXLSX ; MBS("XL.Book.Save"; $$Book_WKPI; $fileName) ]
#
# save result to desktop
Set Variable [ $path ; Value: Get(DesktopPath) & $fileName ]
Export Field Contents [ SheetCopy::ResultXLSX ; “$Path” ; Automatically open ; Create folders: Off ]
#
# Cleanup
Set Variable [ $r ; Value: MBS( "XL.Book.Release"; $$Book_MKPI ) ]
Set Variable [ $r ; Value: MBS( "XL.Book.Release"; $$Book_WKPI ) ]

See also

Release notes

Blog Entries

This function checks for a license.

Created 7th December 2016, last changed 16th September 2022


XL.CopyRow - XL.Date.DoubleToTimeStamp