Copying an Excel file to a table's dataset

Updrading Ignition to the latest (8.1.42, as of this writing) will update POI from 3.1.7 to 4.1.2.

When I originally posted this question, it took me awhile to find a solution that worked for me. I have only used it on one project the whole time. My solution was to copy each column in to a dataset from the excel sheet. I created a screen with a table that displays the dataset and a submit button. The submit button has a simple script to insert it into the database table. In the end it was a work around but it worked.
Screen Shot

Script

#imports
import system

#get data from dataset
data = event.source.parent.getComponent('Table').data

for insertrow in range(0,data.getRowCount()):
	query = "INSERT INTO PartsLocation(Location) VALUES(?)"
	args = [data.getValueAt(insertrow, 0)]
	system.db.runPrepUpdate(query, args)


I have upgraded Ignition and now it seems to work... Really strange :slight_smile:

How to link excel to dataset function filepath with the file upload component. Actually i am trying to pass the file path dynamically so user will be able to select the file path

You cannot supply a file path to an Upload component. That would be malware-ish behavior. The user must always control where the file comes from in their system.

2 Likes

nice job @JordanCClark , it works with the example files but i´ve a file with the next sequenece
test.xlsx (10.4 KB)
i try change to diferent formats but i can´t find the issue.

Your first column has differing datatypes. Excel doesn't give a wet slap what you format the cells for.

I have revamped the processing a bit. You can find it on my GitHub page.

Assuming you use the same package structure I show there, the functions of interest will be:

  • util.dataset.fromExcel()
  • util.dataset.fromExcelBytes() -- useful for using with perspective
  • util.dataset.processExceltoDataset()