跳至内容
菜单
此问题已终结

I have a model:

class my_reports(osv.osv):
_name = "my.reports"    
_description = "My reports"
_columns = {
            'pdf_file':fields.binary("PDF File", readonly=True),
            'pdf_file_name':fields.char("PDF File Name", 128, readonly=True),
            'file':fields.binary("Spreadsheet File", readonly=True),
            'file_name':fields.char("Spreadsheet File Name", 128, readonly=True),
        }
my_reports()

Now I would like to generate pdf & spread sheet. I do that with Reporatlab & Xlwt.

import reportlab
from reportlab.pdfgen import canvas

import StringIO
import base64
from xlwt import *
import xlwt

def hello(c):
    c.drawString(100,100,"My pdf")

def generate_payslip_pdf():    
    c = canvas.Canvas("my.pdf")
    hello(c)
    c.showPage()
    c.save()    
    return c

def generate_payslip_xls():    
    wbk = xlwt.Workbook()
    sheet1 = wbk.add_sheet('my sheet')  

    file_data=StringIO.StringIO()
    o=wbk.save(file_data)    
    out=base64.encodestring(file_data.getvalue())
    return out

No I want to download in correct pdf file or xls file, which is not happening.

I am using the my_reports as one2many in another model and is trying to write the generated content to the fields.

形象
丢弃

Do you have a solution for your problem ?

did u manage to solve the problem?

相关帖文 回复 查看 活动
PDF reports 已解决
5
7月 25
2224
2
3月 24
2733
0
11月 22
2960
0
9月 17
5268
0
3月 15
3645