Importing xlrd library for reading Excel files

Hi all!

After reading and trying different solutions from the forum I am unable to do the following:

  • I have an Excel file (with only one sheet) I want to read using an external python library (i.e. xlrd) and write the contents of that sheet into a dataset memory tag.

I have tried with this example and some other posts on the forum: Microsoft excel 2010 - #2 by bkarabinchak.psi
Ignition 8.1: Excel Import & Export tool for Ignition Tags - #8 by pturmel

I copied the xlrd folder under both the “\user-lib\pylib\site-packages” and “\user-lib\pylib”:


I have a perspective view with a button and a label and the code is:

import xlrd
location = “C:\Users\GENIOTIC\Desktop\PruebasIgnition\PruebaExcel.xls”
book = xlrd.open_workbook(location)
self.getSibling(“Label”).props.text = book.nsheets

Ignition version is 8.1.

Could anyone give me a tip here? I already tried clearing the cache and restarting the gateway.

In the newer versions of xlrd, it is possible to read “.xlsx” files?

Thanks in advance,

seems you might want to take an older version of xlrd

what is the error you are getting tho?

Consider not using xlrd at all. Ignition 8.1 includes the Apache POI libraries, which are native java tools for MS office documents. This topic covers the basics:

3 Likes

Dear all,

I used this solution as indicated by @pturmel

Works as I expected.

Thanks!!!

Kudos to @JordanCClark for excellent examples.

3 Likes