And most importantly, you can utilize the functionality of any remote libraries that you've loaded. At that point, you can use JSEngine's ExecuteJavaScriptSync method to run JavaScript code and get back the results. When an instance of the JSEngine class is opened, it automatically loads a simple HTML page that includes references to the remote libraries (via "script" tags in the document's head). The Libraries property is an array, so you can use it to load multiple libraries. ![]() (For example, the URL to the SheetJS library is: ) To load a JavaScript library, you add an element to the array, and do so in the Opening event handler for the class instance. Each element of the array represents a remote JavaScript library's URL. JSEngine has a "Libraries" property, which is an array of strings. To get started, I developed a subclass of the DesktopHTMLViewer control called "JSEngine." My goal with JSEngine was to make it easy to load JavaScript libraries. Here's a link to a zip file that contains two Xojo project files: The projects include the classes and code that I'm about to discuss. I'll also share two classes - JSEngine (a subclass of Xojo's DesktopHTMLViewer control that makes it easy to work with external JavaScript libraries) and ExcelEngine (a subclass of JSEngine that makes it easy to work with SheetJS). In this post, I'll show how you can use popular JavaScript libraries in Xojo desktop projects. That got me thinking: I could utilize SheetJS by using a Xojo DesktopHTMLViewer control and its ExecuteJavaScriptSync method. ![]() For those projects I used the popular SheetJS JavaScript library, and had a lot of success with it. In the past, I've developed Web applications that also needed to generate Excel files. I reached a point where I needed to export the price lists as Excel files. ![]() The app generates price lists using somewhat complex business logic. A few weeks ago, I used Xojo to develop a custom macOS / Windows desktop application for a client.
0 Comments
Leave a Reply. |