Platforms to show: All Mac Windows Linux Cross-Platform

/XL/Invoice with Template for Web/Invoice with Template for Web


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/Invoice with Template for Web/Invoice with Template for Web

This example is the version from Mon, 6th Nov 2022.

Project "Invoice with Template for Web.xojo_binary_project"
Class App Inherits WebApplication
EventHandler Sub Opening(args() as String) RegisterLibXL 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
Class Session Inherits WebSession
Const ErrorDialogCancel = "Do Not Send"
Const ErrorDialogMessage = "This application has encountered an error and cannot continue."
Const ErrorDialogQuestion = "Please describe what you were doing right before the error occurred:"
Const ErrorDialogSubmit = "Send"
Const ErrorThankYou = "Thank You"
Const ErrorThankYouMessage = "Your feedback helps us make improvements."
Const NoJavascriptInstructions = "To turn Javascript on, please refer to your browser settings window."
Const NoJavascriptMessage = "Javascript must be enabled to access this page."
End Class
Class WebPage1 Inherits WebPage
Control Button1 Inherits WebButton
ControlInstance Button1 Inherits WebButton
EventHandler Sub Pressed() System.DebugLog "Button pressed" // create new xls file dim book as new XLBookMBS(false) // load template dim f as FolderItem = FindFile("Template.xls") if f = nil then MessageBox "Failed to find template." Return end if System.DebugLog f.NativePath call book.Load(f) dim sheet as XLSheetMBS = book.Sheet(0) // create sheet 'dim sheet as XLSheetMBS = book.AddSheet("Sheet1") // Write Customer address call sheet.WriteString 5, 1, "Smith & Co" call sheet.WriteString 6, 1, "First Avenue 123" call sheet.WriteString 7, 1, "12345 New York" call sheet.WriteString 9, 1, "Bob Smith" // Write Header call sheet.WriteString 13, 2, "123-456" call sheet.WriteString 13, 3, "789-123" call sheet.WriteString 13, 4, "UPS" // Write items dim sum as Double = 0 call sheet.WriteNumber 18, 0, 1 call sheet.WriteString 18, 1, "Box of Apples" call sheet.WriteNumber 18, 5, 19.95 call sheet.WriteNumber 18, 6, 19.95*1 sum = sum + 19.95 call sheet.WriteNumber 19, 0, 5 call sheet.WriteString 19, 1, "Box of Peaches" call sheet.WriteNumber 19, 5, 24.95 call sheet.WriteNumber 19, 6, 24.95*5 sum = sum + 24.95*5 // Write Sum call sheet.WriteNumber 29, 6, sum call sheet.WriteNumber 30, 6, 9.99 sum = sum + 9.99 call sheet.WriteNumber 31, 6, sum // Write bank account call sheet.WriteString 34, 2, "Smith & Co" call sheet.WriteString 35, 2, "123456789" // Write Footer call sheet.WriteString 42, 0, "Smith & Co" call sheet.WriteString 43, 0, "First Avenue 12344, LA 12345 New York" call sheet.WriteString 44, 0, "Phone 123-456-789-0, Fax 123-456-789-1, email@test.invalid, www.test.invalid" // write file w = new WebFile dim data as string if book.SaveRaw(data) then w.MIMEType = "application/vnd.ms-excel" w.Data = data w.Filename = "test.xls" w.ForceDownload = true GoToURL w.URL else MessageBox "Failed to write xls file." end if End EventHandler
End Control
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
Property w As WebFile
End Class
Sign
End Sign
End Project

See also:

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


The biggest plugin in space...