Platforms to show: All Mac Windows Linux Cross-Platform

XLBookMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class XL MBS XL Plugin 11.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The central class for a workbook.
Example
// create new Excel file, pass true for XLSX format or false for older XLS format
Dim book As New XLBookMBS(True)

// add sheet
Dim sheet As XLSheetMBS = book.addSheet("Test")
Call sheet.WriteString(2, 1, "Hello World", Nil)

// write file and launch
Dim file As FolderItem = SpecialFolder.Desktop.Child("Writing data.xlsx")

If book.Save(file) Then
file.Launch
Else
MsgBox "Failed to create file."+EndOfLine+EndOfLine+book.ErrorMessage
End If

The MBS Xojo XL Plugin is based on LibXL, a powerful library to handle Excel files.

You'll need your own license for LibXL. For more information go here:
https://www.monkeybreadsoftware.de/xojo/plugin-xls.shtml

When you have obtained license file inside your XOJO project place XLBookMBS.SetKeyGlobal call with LibXL license in app.open.

  • 10 properties
  • 73 methods
    • method AddConditionalFormat as XLConditionalFormatMBS   New in 24.2
    • method AddCustomNumFormat(customNumFormat as string) as Integer
    • method AddFont(initFont as XLFontMBS = nil) as XLFontMBS
    • method AddFormat(initFormat as XLFormatMBS = nil) as XLFormatMBS
    • method AddFormatFromStyle(style as Integer) as XLFormatMBS
    • method AddPicture(path as folderitem) as Integer
    • method AddPicture(path as string) as Integer
    • method AddPictureData(data as string) as Integer
    • method AddRichString as XLRichStringMBS
    • method AddSheet(name as string, initSheet as XLSheetMBS = nil) as XLSheetMBS
    • method AddStyledText(StyledText as StyledText) as XLRichStringMBS
    • method BookVersion as Integer
    • method Constructor(xml as boolean = false)
    • method CopyContent(dest as XLBookMBS, Options as XLCopyOptionsMBS = nil)
    • method CustomNumFormat(fmt as Integer) as string
    • method DefaultFont(byref fontSize as Integer) as string
    • method DelSheet(index as Integer) as boolean
    • method Font(index as Integer) as XLFontMBS
    • method FontCount as Integer
    • method Fonts as XLFontMBS()
    • method Format(index as Integer) as XLFormatMBS
    • method FormatCount as Integer
    • method Formats as XLFormatMBS()
    • method InsertSheet(index as Integer, name as string = "", initSheet as XLSheetMBS = nil) as XLSheetMBS
    • method Load(path as folderitem) as boolean
    • method Load(path as string) as boolean
    • method LoadMT(path as folderitem) as boolean
    • method LoadMT(path as string) as boolean
    • method LoadPartially(path as folderitem, sheetIndex as Integer, firstRow as Integer, lastRow as Integer, keepAllSheets as Boolean = false) as boolean
    • method LoadPartially(path as string, sheetIndex as Integer, firstRow as Integer, lastRow as Integer, keepAllSheets as Boolean = false) as boolean
    • method LoadPartiallyUsingTempFile(path as folderitem, sheetIndex as Integer, firstRow as Integer, lastRow as Integer, TempFile as folderitem, keepAllSheets as Boolean = false) as boolean
    • method LoadPartiallyUsingTempFile(path as string, sheetIndex as Integer, firstRow as Integer, lastRow as Integer, TempFile as String, keepAllSheets as Boolean = false) as boolean
    • method LoadRaw(data as MemoryBlock) as boolean
    • method LoadRaw(data as string) as boolean
    • method LoadRawMT(data as MemoryBlock) as boolean
    • method LoadRawMT(data as string) as boolean
    • method LoadRawPartially(data as MemoryBlock, sheetIndex as Integer, firstRow as Integer, lastRow as Integer, keepAllSheets as Boolean = false) as boolean
    • method LoadRawPartially(data as string, sheetIndex as Integer, firstRow as Integer, lastRow as Integer, keepAllSheets as Boolean = false) as boolean
    • method LoadUsingTempFile(path as folderitem, TempFile as folderitem) as boolean
    • method LoadUsingTempFile(path as string, TempFile as String) as boolean
    • method MoveSheet(SourceIndex as integer, DestIndex as Integer) as boolean
    • method PackColor(ColorValue as color) as Integer
    • method PackColor(red as Integer, green as Integer, blue as Integer) as Integer
    • method PackDate(d as date) as Double
    • method PackDate(year as Integer, month as Integer, day as Integer, hour as Integer = 0, min as Integer = 0, sec as Integer = 0, msec as Integer = 0) as Double
    • method PackDateTime(d as dateTime) as double
    • method Picture(index as Integer, byref data as string) as Integer
    • method PictureCount as Integer
    • method Save(path as folderitem) as boolean
    • method Save(path as folderitem, UseTempFile as Boolean) as boolean
    • method Save(path as string) as boolean
    • method Save(path as string, UseTempFile as Boolean) as boolean
    • method SaveMT(path as folderitem) as boolean
    • method SaveMT(path as string) as boolean
    • method SaveRaw(byref data as MemoryBlock) as boolean
    • method SaveRaw(byref data as string) as boolean
    • method SaveRawMT(byref data as MemoryBlock) as boolean
    • method SaveRawMT(byref data as string) as boolean
    • method SetDefaultFont(fontName as string, fontSize as Integer)
    • method SetKey(name as string, key as string)
    • method SetKeyGlobal(name as string, key as string)   Private
    • method SetLocale(locale as string)
    • method Sheet(index as Integer) as XLSheetMBS
    • method SheetCount as Integer
    • method Sheets as XLSheetMBS()
    • method SheetType(index as Integer) as Integer
    • method UnpackColor(ColorValue as Integer) as color
    • method UnpackColor(ColorValue as Integer, byref red as Integer, byref green as Integer, byref blue as Integer)
    • method UnpackDate(Value as Double) as date
    • method UnpackDate(Value as Double, byref year as Integer, byref month as Integer, byref day as Integer) as boolean
    • method UnpackDate(Value as Double, byref year as Integer, byref month as Integer, byref day as Integer, byref hour as Integer, byref min as Integer, byref sec as Integer) as boolean
    • method UnpackDate(Value as Double, byref year as Integer, byref month as Integer, byref day as Integer, byref hour as Integer, byref min as Integer, byref sec as Integer, byref msec as Integer) as boolean
    • method UnpackDateTime(Value as double) as dateTime
  • 15 shared methods
    • shared method available as boolean
    • shared method LibVersion as string
    • shared method LibVersionNumber as Integer
    • shared method Load2(path as folderitem) as XLBookMBS
    • shared method Load2(path as folderitem, byref ErrorMessage as String) as XLBookMBS
    • shared method Load2(path as string) as XLBookMBS
    • shared method Load2(path as string, byref ErrorMessage as String) as XLBookMBS
    • shared method LoadError as String
    • shared method LoadLibrary(File as FolderItem) as boolean
    • shared method LoadLibrary(Path as string) as boolean
    • shared method LoadRaw2(data as MemoryBlock) as XLBookMBS
    • shared method LoadRaw2(data as MemoryBlock, byref ErrorMessage as String) as XLBookMBS
    • shared method LoadRaw2(data as string) as XLBookMBS
    • shared method LoadRaw2(data as string, byref ErrorMessage as String) as XLBookMBS
    • shared method SetKeyGlobal(name as string, key as string)
  • 64 constants

This class has no sub classes.

Some methods using this class:

Some properties using for this class:

Some examples using this class:

Blog Entries

Xojo Developer Magazine

Release notes

  • Version 24.2
    • Added keepAllSheets parameter for LoadPartially methods in XLBookMBS class.
    • Added PictureTypeSVG constant for XLBookMBS class.
  • Version 23.3
    • Added AddFormatFromStyle method for XLBookMBS class.
  • Version 23.1
    • Added IsWriteProtected method to XLBookMBS class.
  • Version 20.1
    • Fixed a problem with returning dates in Xojo which affects XLBookMBS.UnpackDate function and others.
  • Version 18.4
  • Version 18.3
    • Added SetKeyGlobal private method to XLBookMBS class to cause compiler error if you call SetKeyGlobal with an object. Please call only in app.open with shared method.
    • Changed DynaPDFMBS.SetLicenseKeyGlobal and XLBookMBS.SetKeyGlobal to raise exception if debugging, if called twice to notify developer about misuse.
  • Version 17.5
    • Added MT methods to XLBookMBS class to load/save thread friendly.
  • Version 17.3
    • Added XLBookMBS methods to load partially and load/save with temp file.
  • Version 17.2

The items on this page are in the following plugins: MBS XL Plugin.


XLAutoFilterMBS   -   XLConditionalFormatMBS


The biggest plugin in space...