def execute(self, context, filepath, sheets=None, workbook_handler=None):
if filepath is None:
# ???????????
filepath = "/tmp/{}_{}.xlsx".format(
int(time.time()), random.randint(100, 999))
workbook = xlsxwriter.Workbook(filepath)
elif filepath.startswith("memory:"):
output = StringIO()
workbook = xlsxwriter.Workbook(output, {'in_memory': True})
context[filepath[len("memory:"):]] = output
else:
workbook = xlsxwriter.Workbook(filepath)
for sheet in sheets:
sheet(context, workbook)
if workbook_handler:
workbook_handler(workbook)
workbook.close()
return filepath
评论列表
文章目录