exportExcel() files with t_stamp and value fields from easyCharting

Good morning everyone,
I have a little problem and I would like to know if there is a method that I am not using well. :sweat_smile:

I want to export by means of a button, all the values that are selected in the easyCharting, at the moment it shows me the fields NAME and GROUP_NAME of the pens (just what I need).

in addition to this I want to show me T_STAMP and the VALUE that is currently taking in the table. can I do that?

este es el codigo que tengo actualmente, es un script onlick de on boton

this is the code that I have at the moment, it is a script onlick of on button

# Get the Dataset component named "DDBB"
data_ddbb = event.source.parent.getComponent('DDBB').pens

# get the column index of the enabled column to filter data
enabled_column_index = data_ddbb.getColumnIndex("ENABLED")

# Create a list that will become a list of lists for a dataset
data = []

# Get the column headers from the pens dataset
headers = ["NAME", "GROUP_NAME"] 
print headers
# iterate through each row of the pens dataset to see if the pen is enabled
for row in range(data_ddbb.rowCount):
	if data_ddbb.getValueAt(row, enabled_column_index):
		# Create a row list for the row data 
		rowData = []
		# iterate through each column to get the row data
		for column in range(data_ddbb.columnCount):
			rowData.append(data_ddbb.getValueAt(row, column))

		# append the row list to the main list
# Create a dataset with the selected pens data for exporting to Excel
selectedData = system.dataset.toDataSet(headers, data)

# Export the dataset
file_path = system.dataset.exportExcel("SelectedData", True, selectedData)


No, the pens dataset is just configuration for what to show on the chart. It does not contain any of the displayed data. For the EasyChart, you will need to go "under the hood" with the implementation's JFreeChart objects to access the displayed data and pick out the points of interest.

I have already made a drastic change in the code, now I am looking for it through the exportDatasets

Dataset = event.source.parent.getComponent('DDBB')

Dataset_data = Dataset.exportDatasets()[1]
print Dataset_data
Dataset_Sheet_Names = ["data"]
path = system.dataset.exportExcel("SelectedData",True,Dataset_data)
SpreadSheet = system.dataset.toExcel(True,Dataset_data, True, Dataset_Sheet_Names)
system.file.writeFile(path, SpreadSheet)

this is the table with the data that I want to extract

and this is the excel result:

now I want to add to excel the column GROUP_NAME, to determine where each value comes from, because I am extracting the data without knowing which is which.

Ah, you are after the values associated with an X-Trace.

I'm pretty sure that this has been answered in detail at some point, but I don't keep up with that. I just use my EasyNoteChart (from my NoteChart 3rd-party module) component in place of any EasyChart. My NoteChart components provide this exact functionality as a standard component property samples aka "Pen Value Samples".

mm sounds like a solution heheh, I don't think that at this stage of the project I can implement a new module, I'll try, but for now I'll just export it with the easychart button.

thanks again Phill.

You don't have to implement a module--mine is available for purchase in the 3rd party module showcase. (:

1 Like