Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/XL/Custom Number Formats
Required plugins for this example: MBS XL Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /XL/Custom Number Formats
This example is the version from Sun, 20th Jan 2018.
Project "Custom Number Formats.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() RegisterLibXL // create new xls file dim book as new XLBookMBS(false) // create formats dim F(6) as integer dim Formats(6) as XLFormatMBS f(0) = book.AddCustomNumFormat( "0.0") f(1) = book.AddCustomNumFormat( "0.00") f(2) = book.AddCustomNumFormat( "0.000") f(3) = book.AddCustomNumFormat( "0.0000") f(4) = book.AddCustomNumFormat( "#,###.00 $") f(5) = book.AddCustomNumFormat( "#,###.00 $[Black][<1000];#,###.00 $[Red][>=1000]") for i as integer = 0 to 5 formats(i) = Book.AddFormat Formats(i).NumFormat = f(i) next // create sheet dim sheet as XLSheetMBS = book.AddSheet("Custom Number Formats") // write some values call sheet.SetCol(0, 0, 20) call sheet.WriteNumber( 2, 0, 25.718, formats(0)) call sheet.WriteNumber( 3, 0, 25.718, formats(1)) call sheet.WriteNumber( 4, 0, 25.718, formats(2)) call sheet.WriteNumber( 5, 0, 25.718, formats(3)) call sheet.WriteNumber( 7, 0, 1800.5, formats(4)) call sheet.WriteNumber( 9, 0, 500.0, formats(5)) call sheet.WriteNumber(10, 0, 1600.0, formats(5)) // write file dim file as FolderItem = SpecialFolder.Desktop.Child("Custom Number Formats.xls") if book.Save(file) then file.Launch else MsgBox "Failed to create file."+EndOfLine+EndOfLine+book.ErrorMessage end if quit End EventHandler
Sub RegisterLibXL() // once you bought a LibXL license, you can put your license key here // see order links on our website // http://www.monkeybreadsoftware.de/xojo/plugin-xls.shtml #if TargetMacOS then XLBookMBS.SetKeyGlobal "your name", "your Mac LibXL license key" #elseif TargetWin32 then XLBookMBS.SetKeyGlobal "your name", "your Windows LibXL license key" #elseif TargetLinux then XLBookMBS.SetKeyGlobal "your name", "your Linux LibXL license key" #endif End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

Feedback, Comments & Corrections

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

MBS Xojo tutorial videos