0

我可以使用以下代码保存 Excel 文件:

f = cStringIO.StringIO()  # This is a buffer to Store the above values
wb.save(f)  # This will save the buffer
output_data=base64.encodestring(f.getvalue()) 
res = self.write(cr, uid, ids, {'state':'get','data':output_data, 'name':'kpi.xls'}, context=context)
return res 

但我无法使用另存为向导保存 CSV 文件。

4

1 回答 1

0

代码和解释不完整,但据我了解,您需要一个“另存为”对话框。Tkinter中的tkFileDialog应该可以解决问题。

 filename = tkFileDialog.asksaveasfilename()
res = self.write(cr, uid, ids, {'state':'get','data':output_data, 'name':filename}, context=context)
于 2012-07-26T07:13:16.437 回答