Open excel file

Hello everyone
Xojo

Thankful for your answers

how to open an excel file and display the contents of a cell in a text field?
Some example code

Cordially,

Raul

Xojo has no inherent support for Excel files.

If you are dealing with a *.xlsx file, they are stored as XML so you could load it as a XML document and extract what you want. If you are looking for something easier, two third-party alternatives are ExcelReader from Einhugur and the MBS XL Plugin available separately or as part of a package offering. Unlike most MBS plugins, this one is a wrapper to yet another product which also must be licensed. See also LibXL

Hello Raul,

Xojo has a free plugin that supports Excel in Windows.

Copy Xojo’s plugin from the location: C:\Program Files\Xojo\Xojo 2018r2\Extras\PluginsSDK
Paste it in the location: C:\Program Files\Xojo\Xojo 2018r2\Plugins

Here is Example 3-3 from the book I Wish I Knew How to Program Excel 2016 with Xojo in Windows:

[code]Dim excel as new ExcelApplication
Dim A, B as double
excel.visible = true
excel.workbooks.add

excel.Range(“A1”).value = “Gallons”
excel.Range(“A2”).value = 30
excel.Range(“A3”).value = “30.5”

A = excel.Range(“A2”).value
B = excel.Range(“A3”).value

MsgBox("A2 = " + str(A) + ", A3 = " + str(B))

Excel = Nil

Exception err as OLEException
MsgBox err.message
[/code]

There is much code in the forums, and more information is on the Xojo Docs at: http://documentation.xojo.com/index.php/Office_Automation

A book with over 100 examples is also available for purchase at http://xojolibrary.com/

True enough. I had forgotten about this because it is Windows only and (last I knew) also required the actual Office applications installed on the machine. That did not ever fit my use cases, but it very well may others.

Thank you Douglas
Thank you Eugene

I really have an excel file already generated by another application, what I need is to show the contents of a cell of that excel file in xojo

some other idea or example

Cordially,

If you are running on Windows AND have Excel on the target machine, Eugene’s method is free and simple.

If you don’t, then if it is *.xlsx format you can parse the XML contents and still be free. If you don’t want to do that, or it is *.xls format, then I pointed out two third party solutions available.

What else you looking for? (Rhetorical question: I gave you my ideas)

If the Excel file is a proper structured data table, you can access the content via ODBC using the ODBCDatabase class. For Mac there are Drivers from Acutal Tech, on Windows Microsoft should provide them.

Thank you so much
Tobias

It is a file with Excel with one column and several rows, the column is in the form of a General type cell.

Very grateful for any help

Cordially,

Raul