Think of it like automating data entry and then automating the act of opening the file in excel after the file has been created.
My current code isn't rely relevant to the question but ere it is anyways:
##crac unit reporting... import xlwt from datetime import datetime class Unit(): def __init__(self, name="unknown", temperature=0, humitty = 0): self.name = name self.temperature = temperature self.humitty = humitty def sys_health(self): if self.temperature > 85: #print self.temperature #for debug use print "Temperature is out of tolerance!" else: print "Temperature is within tolerance!" if self.humitty > 60: #print self.humitty #for debug use print "Humitty is out of tolerance!" else: print "Humitty is within tolerance!" wb = xlwt.Workbook() ws = wb.add_sheet("A test sheet") #this is to create the sheet but I need to change this to something relevant later #This is the first Row/Column to be written to for the crac unit's ID. unitIdRow = 1 unitIdColumn = 1 #This is the first Row/Column to be written to for the first units temperature. unitTempRow = 3 unitTempColumn = 1 #This is the first Row/Column to be written to for the first units humitty. unitHumittyRow = 3 unitHumittyColumn = 2 #This is the first Row/Column to be written to for the Designation of temperature column's. tempDesignationRow = 2 tempDesignationColumn = 1 #This is the first Row/Column to be written to for the Designation of humitty column's. humittyDesignationRow = 2 humittyDesignationColumn = 2 active_units = ['crac-1', 'crac4', 'crac5', 'crac9', 'crac10', 'crac12', 'crac15', 'crac16', 'crac17', 'crac18', 'crac19', 'crac20', 'crac21', 'crac22', 'crac23', 'crac24', 'crac26'] #Need to have a way of altering this list for I in active_units: # This loop is for printing the headers that should not be reprinted. ws.write( tempDesignationRow, tempDesignationColumn, "Temp.") tempDesignationColumn = tempDesignationColumn + 2 ws.write( humittyDesignationRow, humittyDesignationColumn, "Humitty") humittyDesignationColumn = humittyDesignationColumn + 2 for i in active_units: #This loop is for getting temp and humitty from the user and writing them to spreadsheet. print "__________________________________________________________" print "Current unit %s " % i ws.write( unitIdRow, unitIdColumn, i) unitIdColumn = unitIdColumn + 2 currentUnitTemp = int(raw_input("Enter the current temperature for unit %s: " % i)) ws.write( unitTempRow, unitTempColumn, currentUnitTemp) unitTempColumn = unitTempColumn + 2 currentUnitHumitty = int(raw_input("Enter the current humitty for unit %s: " % i)) ws.write( unitHumittyRow, unitHumittyColumn, currentUnitHumitty) unitHumittyColumn = unitHumittyColumn + 2 i = Unit(i, currentUnitTemp, currentUnitHumitty) i.sys_health() print "__________________________________________________________" print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" #Save mechanism saveAs = raw_input("Save file as: ") saveAs = saveAs + ".xls" print "Saving as: %s" % saveAs wb.save(saveAs) #May want to automate this at some point for easy of use and standardization reasons.