经过多次试验和错误,我找到了答案!在我的例子,我有一个名为“jd_gross”我想在我的报告总查询集现场....我终于放弃了行动= FIELD_ACTION_SUM节并推出我自己的
在我band_detail部分我可以显示该现场用逗号改为:
ObjectValue(attribute_name='jd_gross', left=26.7*cm, width=1.7*cm, style={'alignment':TA_RIGHT}, get_value=lambda instance: intcomma(instance.jd_gross)),
为我的作品的摘要部分是但要添加到答案: 高清初始化(个体经营,* ARGS,** kwargs): 部分,之后: self.band_page_header.elements + = [ 我使用了相同的概念来计算我的比例L,将其转换为格式化字符串,并在我的总结部分添加一行作为系统领域如下:
myset = self.queryset
grosstotal = 0
for myline in myset:
if myline.jd_gross:
grosstotal += myline.jd_gross
ugrosstotal = intcomma(grosstotal)
self.band_summary.elements += [
SystemField(expression=ugrosstotal, top=1*cm, left=26.5*cm, width=1.9*cm, style={'alignment':TA_RIGHT}),
]
,所以我完全继承报告如下内容:
类JobdetailsReport(DefaultReport) : 标题= '作业详细信息' PAGE_SIZE =景观(A4)
class band_detail(DetailBand):
height=0.7*cm
elements=[
ObjectValue(attribute_name='jd_job', left=0.1*cm),
ObjectValue(attribute_name='c_name', left=1.5*cm),
ObjectValue(attribute_name='clientname', left=5.8*cm),
ObjectValue(attribute_name='jd_return', left=10.1*cm),
ObjectValue(attribute_name='jd_delivery', left=12.6*cm),
ObjectValue(attribute_name='get_j_status1_display', left=15.1*cm),
ObjectValue(attribute_name='get_j_status2_display', left=17.6*cm),
ObjectValue(attribute_name='jd_prodref', left=20.1*cm),
ObjectValue(attribute_name='userformalname', left=23*cm),
ObjectValue(attribute_name='jd_gross', left=26.7*cm, width=1.7*cm, style={'alignment':TA_RIGHT}, get_value=lambda instance: intcomma(instance.jd_gross)),
]
borders = {'bottom': True}
class band_summary(ReportBand):
height = 1.7*cm
elements = [
Label(text='Records printed:', top=1*cm, left=0.5*cm),
ObjectValue(expression='count(jd_job)', top=1*cm, left=5.6*cm),
Label(text="Total Value:", top=1*cm, left=22*cm),
]
borders = {'top': True}
def __init__(self, *args, **kwargs):
super(JobdetailsReport, self).__init__(*args, **kwargs)
self.band_page_header.elements += [
Label(text="Job No.", top=0.8*cm, left=0.1*cm),
Label(text="Client", top=0.8*cm, left=1.5*cm),
Label(text="Delivery", top=0.8*cm, left=5.8*cm),
Label(text="Return", top=0.8*cm, left=10.1*cm),
Label(text="Delivery", top=0.8*cm, left=12.6*cm),
Label(text="Physical Status", top=0.8*cm, left=15.1*cm),
Label(text="Accts Status", top=0.8*cm, left=17.6*cm),
Label(text="Reference", top=0.8*cm, left=20.1*cm),
Label(text="Our Contact", top=0.8*cm, left=23*cm),
Label(text="Gross", top=0.8*cm, left=27*cm),
]
myset = self.queryset
grosstotal = 0
for myline in myset:
if myline.jd_gross:
grosstotal += myline.jd_gross
ugrosstotal = intcomma(grosstotal)
self.band_summary.elements += [
SystemField(expression=ugrosstotal, top=1*cm, left=26.5*cm, width=1.9*cm, style={'alignment':TA_RIGHT}),
]
希望帮助你!它只花了我几个小时才得到它的工作......
我试过杰拉尔德报告,但你不能把逗号。我喜欢那里的报告格式,但有很多限制。 – catherine 2013-03-28 05:02:52
您发现的任何其他东西可以让django/python轻松制作PDF报告* – 2013-03-29 15:15:49
不,我最终创建了自己的报告 – catherine 2013-03-29 16:08:17