def __writexls__(self, filename="output.xlsx", outputdict={}):
if outputdict is None:
raise ValueError('An output argument was expected')
if not isinstance(outputdict, dict):
raise TypeError('Was expecting a dictionary for outputdict but got a %s' % type(dict))
extension = '.xlsx'
if not filename.endswith(extension):
filename += extension
#TODO check location and filename are valid
workbook = xlsxwriter.Workbook(filename)
for sheet, grid in sorted(outputdict.items()):
worksheet = workbook.add_worksheet(name=sheet[:32]) #worksheet name cannot be more than 32 chars long
if not isinstance(grid, Matrix):
raise TypeError('Expected a Matrix but got a %s' % type(grid))
for i, row in enumerate(grid):
worksheet.write_row(i, 0, row)
workbook.close()
return True
评论列表
文章目录