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
import xlwt
import StringIO
class BatchesOperatorSpreadsheet(plugin.OutputPreparationPlugin):
""" Output the result of demand planning in a format compatible with
Output_viewDownloadFile
""" Output the schedule of operators in an Excel file to be downloaded
"""
def postprocess(self, data):
# XXX the event generator should store its result in data and not in global
# variable.
print "I'm in"
rowIndex=0
scheduleFile = xlwt.Workbook()
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']] = {
# 'name': 'Result.xlsx',
# 'mime_type': 'application/vnd.ms-excel',
# 'data': G.reportResults.xlsx.encode('base64')
# }
# import json
# utilisationString=json.dumps(G.Utilisation, indent=5)
# outputJSONFile=open('Utilisation.json', mode='w')
# outputJSONFile.write(utilisationString)
scheduleStringIO = StringIO.StringIO()
scheduleFile.save(scheduleStringIO)
encodedScheduleFile=scheduleStringIO.getvalue().encode('base64')
data['result']['result_list'][-1][self.configuration_dict['output_id']] = {
'name': 'Operator_Schedule.xls',
'mime_type': 'application/vnd.ms-excel',
'data': encodedScheduleFile
}
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