excel export: set correct value for percentage, use format with 0 instead of #
parent
1fc11891a0
commit
9d12c136c5
|
@ -501,6 +501,7 @@ class mis_report_instance_period(orm.Model):
|
||||||
'style': kpi_style,
|
'style': kpi_style,
|
||||||
'suffix': kpi.suffix,
|
'suffix': kpi.suffix,
|
||||||
'dp': kpi.dp,
|
'dp': kpi.dp,
|
||||||
|
'is_percentage': kpi.type == 'pct',
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -101,13 +101,15 @@ class mis_builder_xls(report_xls):
|
||||||
num_format_str = '#'
|
num_format_str = '#'
|
||||||
if value.get('dp'):
|
if value.get('dp'):
|
||||||
num_format_str += '.'
|
num_format_str += '.'
|
||||||
for x in range(int(value['dp'])):
|
num_format_str += '0' * int(value['dp'])
|
||||||
num_format_str = num_format_str + '#'
|
|
||||||
if value.get('suffix'):
|
if value.get('suffix'):
|
||||||
num_format_str = num_format_str + ' "%s"' % value['suffix']
|
num_format_str = num_format_str + ' "%s"' % value['suffix']
|
||||||
kpi_cell_style = xlwt.easyxf(_xs['borders_all'] + _xs['right'], num_format_str=num_format_str)
|
kpi_cell_style = xlwt.easyxf(_xs['borders_all'] + _xs['right'], num_format_str=num_format_str)
|
||||||
if value.get('val'):
|
if value.get('val'):
|
||||||
ws.write(row_pos, col, value['val'], kpi_cell_style)
|
val = value['val']
|
||||||
|
if value.get('is_percentage'):
|
||||||
|
val = val / 0.01
|
||||||
|
ws.write(row_pos, col, val, kpi_cell_style)
|
||||||
else:
|
else:
|
||||||
ws.write(row_pos, col, value['val_r'], kpi_cell_style)
|
ws.write(row_pos, col, value['val_r'], kpi_cell_style)
|
||||||
row_pos += 1
|
row_pos += 1
|
||||||
|
|
Loading…
Reference in New Issue