Export dataset to excel with particular cell in vision

Hi Guys,

I'm trying to export the dataset to Excel from a particular cell. Right now export data to Excel successfully but start from cell A1 I have tried to export from cell A4 any idea how to fix this?

Thanks,
Priyanka

If you already have a solution that works for exporting a dataset to excel, the simplest thing would be to remove the rows you don't want from the dataset, then apply your solution to the reduced dataset.

https://docs.inductiveautomation.com/display/DOC81/system.dataset.deleteRows

@pascal.fragnoud Thanks for your response. In my case don't delete any row.

export data from cellA1
My requirement is dataset export from cellA4.

I added an option to offset the export.

sampleHeaders = ['Col1', 'Col2', 'Col3']
sampleData = [['ABC', 123, 9.87],
              ['DEF', 456, 6.54],
              ['GHI', 789, 3.21]
             ]

dataIn = system.dataset.toDataSet(sampleHeaders, sampleData)

util.datasetToExcel(dataIn, 'c:/test/poi offset.xlsx', firstRow=3, firstCol=1)

image

3 Likes

Oh, I misunderstood. Well, Jordan came to the rescue !

It worked perfectly but do you know how to open the URL?

datasetToExcel(dataIn, 'c:/test/poi offset.xlsx', firstRow=3, firstCol=1)

This function directly mentions the file path. I'm trying to open the URL using the below script, but when I use the below hand the particular cell not worked.

system.dataset.exportExcel(fileName, 1, ds)
if filePath != None:
system.net.openURL("file://"+filePath)

EDIT: fixed a mis-spell

# Set save-to path
filePath = system.file.saveFile("myfile.xlsx")

#Process if a save-to path was entered.
if filePath is not None:
	sampleHeaders = ['Col1', 'Col2', 'Col3']
	sampleData = [['ABC', 123, 9.87],
	              ['DEF', 456, 6.54],
	              ['GHI', 789, 3.21]
	             ]
	
	dataIn = system.dataset.toDataSet(sampleHeaders, sampleData)
	
	# Create Excel file
	util.datasetToExcel(dataIn, filePath, firstRow=3, firstCol=1)
	# Open the Excel file
	system.net.openURL("file://"+filePath)
2 Likes

@JordanCClark Thank you so much. Worked Perfectly.
You are a rockstar :innocent: