Commit 8fa9940f authored by Georgios Dagkakis's avatar Georgios Dagkakis

plugin to output the file and column titles included

parent 5fd7874c
from dream.plugins import plugin from dream.plugins import plugin
import xlwt
import StringIO
class BatchesOperatorSpreadsheet(plugin.OutputPreparationPlugin): class BatchesOperatorSpreadsheet(plugin.OutputPreparationPlugin):
""" Output the result of demand planning in a format compatible with """ Output the schedule of operators in an Excel file to be downloaded
Output_viewDownloadFile
""" """
def postprocess(self, data): def postprocess(self, data):
# XXX the event generator should store its result in data and not in global rowIndex=0
# variable. scheduleFile = xlwt.Workbook()
print "I'm in" scheduleSheet = scheduleFile.add_sheet('Operator Schedule', cell_overwrite_ok=True)
scheduleSheet.write(rowIndex,0,'Operator')
scheduleSheet.write(rowIndex,1,'Machine')
scheduleSheet.write(rowIndex,2,'Start Time')
scheduleSheet.write(rowIndex,3,'End Time')
# from dream.simulation.applications.DemandPlanning.Globals import G
# data['result']['result_list'][-1][self.configuration_dict['output_id']] = { scheduleStringIO = StringIO.StringIO()
# 'name': 'Result.xlsx', scheduleFile.save(scheduleStringIO)
# 'mime_type': 'application/vnd.ms-excel', encodedScheduleFile=scheduleStringIO.getvalue().encode('base64')
# 'data': G.reportResults.xlsx.encode('base64') data['result']['result_list'][-1][self.configuration_dict['output_id']] = {
# } 'name': 'Operator_Schedule.xls',
# import json 'mime_type': 'application/vnd.ms-excel',
# utilisationString=json.dumps(G.Utilisation, indent=5) 'data': encodedScheduleFile
# outputJSONFile=open('Utilisation.json', mode='w') }
# outputJSONFile.write(utilisationString)
return data return data
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment