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

XL.Book.AddSheet

Adds a new sheet to this book, returns the sheet index.

Component Version macOS Windows Linux Server iOS SDK
XL 3.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "XL.Book.AddSheet"; bookRef; Name { ; InitSheet } )   More

Parameters

Parameter Description Example Flags
bookRef The reference to the workbook. Please use XL.LoadBook to load a file. $ref
Name The name for the new sheet. "Taxsheet"
InitSheet The index of an existing sheet to use as template.
Must be from the same book to copy sheet.
0 Optional

Result

Returns new sheet index or error message.

Description

Adds a new sheet to this book, returns the sheet index.
Use initSheet parameter if you wish to copy an existing sheet.
Note initSheet must be only from this book.

Examples

Writes sheet with red font:

#create new xls file
Set Variable [$book; Value:MBS( "XL.NewBook"; 0 )]
#create fonts
Set Variable [$redColor; Value:MBS( "XL.Color.Pack"; $book; 255; 0; 0)]
Set Variable [$redFont; Value:MBS( "XL.Book.AddFont"; $book)]
Set Variable [$r; Value:MBS( "XL.Font.SetColor"; $book; $redFont; $redColor)]
#
#create formats
Set Variable [$redFormat; Value:MBS( "XL.Book.AddFormat"; $book)]
Set Variable [$r; Value:MBS( "XL.Format.SetFont"; $book; $redFormat; $redFont)]
#
#create sheet
Set Variable [$sheet; Value:MBS( "XL.Book.AddSheet"; $book; "Sales Receipt")]
#
#add number in red
Set Variable [$r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 5; 3; 123; $redFormat)]
#
Set Field [Writing data::Output; MBS("XL.Book.Save"; $book; "test.xls")]
Set Variable [$r; Value:MBS("XL.Book.Release"; $book)]

See also

Release notes

  • Version 13.0
    • Fixed a problem with XL.Book.AddSheet function not passing correct name each time.

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 18th May 2023


XL.Book.AddPictureFile - XL.Book.BiffVersion