I was trying to append some data to a dataset before exporting to excel (system.dataset.toExcel) to include some parameters that generated that dataset, but I was having a lot of trouble making them append correctly due to datatypes... I finally got it working in Script Console, but I had to use java.util.Date for the date format... which doesn't want to import in Perspective? I kept searching through the documentation but I couldn't find anything else (I feel like there should be a system.date type I could use?). Any advice would be appreciated.
def runAction(self, event):
from java.util import Date
StartDate = self.getSibling("DateTimeInput_Start").props.value
EndDate = self.getSibling("DateTimeInput_End").props.value
Lines = self.getSibling("Dropdown_Source").props.value
Col1 = ['Start Date Filter:', 'End Date Filter:', 'Filter Source: ' + Lines]
Col2 = [StartDate, EndDate]
Data = self.getSibling("Table").props.data
DataRows = Data.getRowCount()
if DataRows < 3:
while DataRows < 3:
Data = system.dataset.addRow(Data, [None, None, None, None, None, None, None])
DataRows = Data.getRowCount()
while len(Col1) < DataRows:
Col1.append('')
while len(Col2) < DataRows:
Col2.append(None)
Data = system.dataset.addColumn(Data, 6, Col1, 'Parameters', str)
Data = system.dataset.addColumn(Data, 7, Col2, 'Parameters ', java.util.Date)
DataOut = system.dataset.toExcel(True, Data)
FileName = 'Report %s.xlsx' % system.date.format(system.date.now(), 'yyyy-MM-dd HH:mm')
system.perspective.download(FileName, DataOut)```