Accessing Microsoft Excel

We can use the Sql class to access Microsoft Excel, as well. For information on interacting with COM or ActiveX, take a look at Groovy’s Scriptom application programming interface (API).[29] In this section we’ll create a really simple example using things we’ve seen already, except that we’ll be talking to Excel instead of MySQL. Let’s first create an Excel file named weather.xlsx (or weather.xls in older versions of Excel).

Create it in the c:\temp directory. The file will contain a worksheet with the name temperatures (see the bottom of the worksheet) and the content shown in Figure 8, An Excel file that we will access using GSQL.

Figure 8. An Excel file that we will access using GSQL

The code to access Excel ...

Get Programming Groovy 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.