Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/XL/Invoice with Template for Web/Invoice with Template for Web
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 Sun, 20th Jan 2018.
Project "Invoice with Template for Web.rbp"
Class App Inherits WebApplication
EventHandler Sub Open() 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 Action() 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 MsgBox "Failed to find template." Return end if System.DebugLog f.AbsolutePath 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 ShowURL w.URL else MsgBox "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
End Project

See also:

Feedback, Comments & Corrections

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

MBS FileMaker Plugins