plugin python, xldr
code:
import xlrd
file = system.file.openFile()
if file != None:
try:
book = xlrd.open_workbook(file,encoding_override="cp1251")
except:
book = xlrd.open_workbook(file)
worksheet = book.sheet_by_index(0)
rows=[]
for i in range(1,1000):
try:
linea=worksheet.cell(i,0).value
PuestoTrabajo=worksheet.cell(i,1).value
oneRow = [linea,PuestoTrabajo]
rows.append(oneRow)
print linea
except:
fila=i-1
print 'Cantidad de filas importadas',' ',fila
break
headers = ["Linea" , " Puesto Trabajo" ]
data = system.dataset.toDataSet(headers, rows)
table = event.source.parent.getComponent('tb_dataPamco')
table.data = data
zacht
June 9, 2023, 5:55pm
2
I don't see a specific question, but I think good general advice is to use the Apache POI library to manipulate import/export/manipulate data in Excel files.
A forum post on the issue:
Consider using the Apache POI Java library that is distributed with Ignition. Ignition v8.0.14 has Apache POI v4.1.1 built-in. As a native java library it will run faster than any python library, and you don’t have to install anything.
1 Like
lrose
June 9, 2023, 6:39pm
3
Except this post is flagged as 7.9 and I'm not sure that the Apache POI library was distributed with any 7.9 build. I would still probably opt for using Apache if I had it available though.
1 Like
zacht
June 9, 2023, 6:42pm
4
Good point. I didn't catch that.
If 7.9 doesn't include them, you can still put the .jar files in the lib/core/common
folder yourself, but it isn't as seamless.