* [Fuego] [PATCH 2/3] ftc: gen-report: Add excel formatter
@ 2018-03-02 3:36 Hoang Van Tuyen
2018-03-07 23:06 ` Tim.Bird
0 siblings, 1 reply; 4+ messages in thread
From: Hoang Van Tuyen @ 2018-03-02 3:36 UTC (permalink / raw)
To: fuego
Add a formatter for excel format. The report file is stored in
${report_dir}. Currently, We always use pts_set_style function
for making the size of column proper. In the future, several
other fields can be added to the report, we can disable using
the pts_set_style function if it is needed
Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
---
engine/scripts/ftc | 68
+++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)
diff --git a/engine/scripts/ftc b/engine/scripts/ftc
index 0b99f94..e0ed13d 100755
--- a/engine/scripts/ftc
+++ b/engine/scripts/ftc
@@ -2077,6 +2077,69 @@ def gen_pdf_report(header_data, report_data,
report_dir):
elements.append(table)
doc.build(elements, onFirstPage=add_page_number,
onLaterPages=add_page_number)
+# support generating the excel report format
+
+# adjust column width size
+# the size of data in fields and header_fields is quite small,
+# so, always use pts_set_style now
+def pts_set_style(ws):
+ dims ={}
+ for row in ws.rows:
+ for cell in row:
+ if cell.value:
+ dims[cell.column] = max((dims.get(cell.column, 0),
len(str(cell.value)) + 2))
+ for col, value in dims.items():
+ ws.column_dimensions[col].width = value
+
+# return number to Excel-style column name
+def excel_column_name(n):
+ name = ""
+ while n > 0:
+ n, r = divmod (n - 1, 26)
+ name = chr(r + ord('A')) + name
+ return name
+
+def gen_excel_report(header_data, report_data, report_dir):
+ from openpyxl import Workbook
+ from openpyxl.style import Fill, Color
+
+ # create an excel file and add worksheets
+ workbook = Workbook()
+ header_sheet = workbook.create_sheet(title="Header")
+ data_sheet = workbook.create_sheet(title="Data")
+
+ # generate header
+ header_sheet.append(["Fuego Test Report"])
+ for field,val_str in header_data:
+ header_sheet.append(["%s: %s" % (field, val_str)])
+ # in future, if we don't want this, use a flag for checking using
pts_set_style
+ pts_set_style(header_sheet)
+
+ # generate lines for this report
+ for item in report_data:
+ data_sheet.append(item)
+ # in future, we can disable this by using a flag
+ pts_set_style(data_sheet)
+
+ # format header row to sheet
+ head_fill = Fill()
+ head_fill.start_color = Color('FFC0C0C0')
+ head_fill.end_color = Color('FFC0C0C0')
+ head_fill.fill_type = Fill.FILL_SOLID
+ for j in range(0, data_sheet.get_highest_column()):
+ data_sheet.cell(row = 0, column = j).style.fill = head_fill
+
+ # add auto filter
+ data_sheet.auto_filter = "A1:" +
excel_column_name(data_sheet.get_highest_column()) +
str(data_sheet.get_highest_row())
+
+ # if we have added sheets, remove the default one ("Sheet")
+ sheets = workbook.get_sheet_names()
+ if len(sheets) > 1:
+ workbook.remove_sheet(workbook.get_sheet_by_name("Sheet"))
+
+ # save the report
+ workbook.save(report_dir + "report.xlsx")
+
# generate a report from run results
def do_gen_report(conf, options):
global quiet, verbose
@@ -2098,7 +2161,7 @@ def do_gen_report(conf, options):
fmt="txt"
if "--format" in options:
fmt = options[options.index("--format")+1]
- if fmt not in ["txt","html","pdf"]:
+ if fmt not in ["txt","html","pdf","excel"]:
error_out("Unsupported format '%s' specified" % fmt)
if "--layout" in options:
@@ -2129,6 +2192,9 @@ def do_gen_report(conf, options):
if fmt=="pdf":
gen_pdf_report(header_data, report_data, report_dir)
sys.exit(0)
+ if fmt=="excel":
+ gen_excel_report(header_data, report_data, report_dir)
+ sys.exit(0)
print report
--
2.1.4
--
================================================================
Hoang Van Tuyen (Mr.)
TOSHIBA SOFTWARE DEVELOPMENT (VIETNAM) CO., LTD.
16th Floor, VIT Building, 519 Kim Ma Str., Ba Dinh Dist., Hanoi, Vietnam
Tel: 84-4-22208801 (Company) - Ext.251
Fax: 84-4-22208802 (Company)
Email: tuyen.hoangvan@toshiba-tsdv.com
================================================================
--
This mail was scanned by BitDefender
For more information please visit http://www.bitdefender.com
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Fuego] [PATCH 2/3] ftc: gen-report: Add excel formatter
2018-03-02 3:36 [Fuego] [PATCH 2/3] ftc: gen-report: Add excel formatter Hoang Van Tuyen
@ 2018-03-07 23:06 ` Tim.Bird
2018-03-08 2:49 ` Hoang Van Tuyen
0 siblings, 1 reply; 4+ messages in thread
From: Tim.Bird @ 2018-03-07 23:06 UTC (permalink / raw)
To: tuyen.hoangvan, fuego
Another problem with word wrapping.
Possibly this is due to your wrap margin settings (or column
width settings) in your e-mail client.
-- Tim
> -----Original Message-----
> From: fuego-bounces@lists.linuxfoundation.org [mailto:fuego-
> bounces@lists.linuxfoundation.org] On Behalf Of Hoang Van Tuyen
> Sent: Thursday, March 01, 2018 7:36 PM
> To: fuego@lists.linuxfoundation.org
> Subject: [Fuego] [PATCH 2/3] ftc: gen-report: Add excel formatter
>
> Add a formatter for excel format. The report file is stored in
> ${report_dir}. Currently, We always use pts_set_style function
> for making the size of column proper. In the future, several
> other fields can be added to the report, we can disable using
> the pts_set_style function if it is needed
>
> Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
> ---
> engine/scripts/ftc | 68
> +++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 67 insertions(+), 1 deletion(-)
>
> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
> index 0b99f94..e0ed13d 100755
> --- a/engine/scripts/ftc
> +++ b/engine/scripts/ftc
> @@ -2077,6 +2077,69 @@ def gen_pdf_report(header_data, report_data,
> report_dir):
> elements.append(table)
> doc.build(elements, onFirstPage=add_page_number,
> onLaterPages=add_page_number)
>
> +# support generating the excel report format
> +
> +# adjust column width size
> +# the size of data in fields and header_fields is quite small,
> +# so, always use pts_set_style now
> +def pts_set_style(ws):
> + dims ={}
> + for row in ws.rows:
> + for cell in row:
> + if cell.value:
> + dims[cell.column] = max((dims.get(cell.column, 0),
> len(str(cell.value)) + 2))
> + for col, value in dims.items():
> + ws.column_dimensions[col].width = value
> +
> +# return number to Excel-style column name
> +def excel_column_name(n):
> + name = ""
> + while n > 0:
> + n, r = divmod (n - 1, 26)
> + name = chr(r + ord('A')) + name
> + return name
> +
> +def gen_excel_report(header_data, report_data, report_dir):
> + from openpyxl import Workbook
> + from openpyxl.style import Fill, Color
> +
> + # create an excel file and add worksheets
> + workbook = Workbook()
> + header_sheet = workbook.create_sheet(title="Header")
> + data_sheet = workbook.create_sheet(title="Data")
> +
> + # generate header
> + header_sheet.append(["Fuego Test Report"])
> + for field,val_str in header_data:
> + header_sheet.append(["%s: %s" % (field, val_str)])
> + # in future, if we don't want this, use a flag for checking using
> pts_set_style
> + pts_set_style(header_sheet)
> +
> + # generate lines for this report
> + for item in report_data:
> + data_sheet.append(item)
> + # in future, we can disable this by using a flag
> + pts_set_style(data_sheet)
> +
> + # format header row to sheet
> + head_fill = Fill()
> + head_fill.start_color = Color('FFC0C0C0')
> + head_fill.end_color = Color('FFC0C0C0')
> + head_fill.fill_type = Fill.FILL_SOLID
> + for j in range(0, data_sheet.get_highest_column()):
> + data_sheet.cell(row = 0, column = j).style.fill = head_fill
> +
> + # add auto filter
> + data_sheet.auto_filter = "A1:" +
> excel_column_name(data_sheet.get_highest_column()) +
> str(data_sheet.get_highest_row())
> +
> + # if we have added sheets, remove the default one ("Sheet")
> + sheets = workbook.get_sheet_names()
> + if len(sheets) > 1:
> + workbook.remove_sheet(workbook.get_sheet_by_name("Sheet"))
> +
> + # save the report
> + workbook.save(report_dir + "report.xlsx")
> +
> # generate a report from run results
> def do_gen_report(conf, options):
> global quiet, verbose
> @@ -2098,7 +2161,7 @@ def do_gen_report(conf, options):
> fmt="txt"
> if "--format" in options:
> fmt = options[options.index("--format")+1]
> - if fmt not in ["txt","html","pdf"]:
> + if fmt not in ["txt","html","pdf","excel"]:
> error_out("Unsupported format '%s' specified" % fmt)
>
> if "--layout" in options:
> @@ -2129,6 +2192,9 @@ def do_gen_report(conf, options):
> if fmt=="pdf":
> gen_pdf_report(header_data, report_data, report_dir)
> sys.exit(0)
> + if fmt=="excel":
> + gen_excel_report(header_data, report_data, report_dir)
> + sys.exit(0)
>
> print report
>
> --
> 2.1.4
>
>
> --
> ==========================================================
> ======
> Hoang Van Tuyen (Mr.)
> TOSHIBA SOFTWARE DEVELOPMENT (VIETNAM) CO., LTD.
> 16th Floor, VIT Building, 519 Kim Ma Str., Ba Dinh Dist., Hanoi, Vietnam
> Tel: 84-4-22208801 (Company) - Ext.251
> Fax: 84-4-22208802 (Company)
> Email: tuyen.hoangvan@toshiba-tsdv.com
> ==========================================================
> ======
>
>
> --
> This mail was scanned by BitDefender
> For more information please visit http://www.bitdefender.com
>
> _______________________________________________
> Fuego mailing list
> Fuego@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Fuego] [PATCH 2/3] ftc: gen-report: Add excel formatter
2018-03-07 23:06 ` Tim.Bird
@ 2018-03-08 2:49 ` Hoang Van Tuyen
2018-03-08 18:39 ` Tim.Bird
0 siblings, 1 reply; 4+ messages in thread
From: Hoang Van Tuyen @ 2018-03-08 2:49 UTC (permalink / raw)
To: Tim.Bird, fuego
[-- Attachment #1: Type: text/plain, Size: 5157 bytes --]
I re-send the patch as an attachment.
On 3/8/2018 6:06 AM, Tim.Bird@sony.com wrote:
> Another problem with word wrapping.
>
> Possibly this is due to your wrap margin settings (or column
> width settings) in your e-mail client.
> -- Tim
>
>> -----Original Message-----
>> From: fuego-bounces@lists.linuxfoundation.org [mailto:fuego-
>> bounces@lists.linuxfoundation.org] On Behalf Of Hoang Van Tuyen
>> Sent: Thursday, March 01, 2018 7:36 PM
>> To: fuego@lists.linuxfoundation.org
>> Subject: [Fuego] [PATCH 2/3] ftc: gen-report: Add excel formatter
>>
>> Add a formatter for excel format. The report file is stored in
>> ${report_dir}. Currently, We always use pts_set_style function
>> for making the size of column proper. In the future, several
>> other fields can be added to the report, we can disable using
>> the pts_set_style function if it is needed
>>
>> Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
>> ---
>> engine/scripts/ftc | 68
>> +++++++++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 67 insertions(+), 1 deletion(-)
>>
>> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
>> index 0b99f94..e0ed13d 100755
>> --- a/engine/scripts/ftc
>> +++ b/engine/scripts/ftc
>> @@ -2077,6 +2077,69 @@ def gen_pdf_report(header_data, report_data,
>> report_dir):
>> elements.append(table)
>> doc.build(elements, onFirstPage=add_page_number,
>> onLaterPages=add_page_number)
>>
>> +# support generating the excel report format
>> +
>> +# adjust column width size
>> +# the size of data in fields and header_fields is quite small,
>> +# so, always use pts_set_style now
>> +def pts_set_style(ws):
>> + dims ={}
>> + for row in ws.rows:
>> + for cell in row:
>> + if cell.value:
>> + dims[cell.column] = max((dims.get(cell.column, 0),
>> len(str(cell.value)) + 2))
>> + for col, value in dims.items():
>> + ws.column_dimensions[col].width = value
>> +
>> +# return number to Excel-style column name
>> +def excel_column_name(n):
>> + name = ""
>> + while n > 0:
>> + n, r = divmod (n - 1, 26)
>> + name = chr(r + ord('A')) + name
>> + return name
>> +
>> +def gen_excel_report(header_data, report_data, report_dir):
>> + from openpyxl import Workbook
>> + from openpyxl.style import Fill, Color
>> +
>> + # create an excel file and add worksheets
>> + workbook = Workbook()
>> + header_sheet = workbook.create_sheet(title="Header")
>> + data_sheet = workbook.create_sheet(title="Data")
>> +
>> + # generate header
>> + header_sheet.append(["Fuego Test Report"])
>> + for field,val_str in header_data:
>> + header_sheet.append(["%s: %s" % (field, val_str)])
>> + # in future, if we don't want this, use a flag for checking using
>> pts_set_style
>> + pts_set_style(header_sheet)
>> +
>> + # generate lines for this report
>> + for item in report_data:
>> + data_sheet.append(item)
>> + # in future, we can disable this by using a flag
>> + pts_set_style(data_sheet)
>> +
>> + # format header row to sheet
>> + head_fill = Fill()
>> + head_fill.start_color = Color('FFC0C0C0')
>> + head_fill.end_color = Color('FFC0C0C0')
>> + head_fill.fill_type = Fill.FILL_SOLID
>> + for j in range(0, data_sheet.get_highest_column()):
>> + data_sheet.cell(row = 0, column = j).style.fill = head_fill
>> +
>> + # add auto filter
>> + data_sheet.auto_filter = "A1:" +
>> excel_column_name(data_sheet.get_highest_column()) +
>> str(data_sheet.get_highest_row())
>> +
>> + # if we have added sheets, remove the default one ("Sheet")
>> + sheets = workbook.get_sheet_names()
>> + if len(sheets) > 1:
>> + workbook.remove_sheet(workbook.get_sheet_by_name("Sheet"))
>> +
>> + # save the report
>> + workbook.save(report_dir + "report.xlsx")
>> +
>> # generate a report from run results
>> def do_gen_report(conf, options):
>> global quiet, verbose
>> @@ -2098,7 +2161,7 @@ def do_gen_report(conf, options):
>> fmt="txt"
>> if "--format" in options:
>> fmt = options[options.index("--format")+1]
>> - if fmt not in ["txt","html","pdf"]:
>> + if fmt not in ["txt","html","pdf","excel"]:
>> error_out("Unsupported format '%s' specified" % fmt)
>>
>> if "--layout" in options:
>> @@ -2129,6 +2192,9 @@ def do_gen_report(conf, options):
>> if fmt=="pdf":
>> gen_pdf_report(header_data, report_data, report_dir)
>> sys.exit(0)
>> + if fmt=="excel":
>> + gen_excel_report(header_data, report_data, report_dir)
>> + sys.exit(0)
>>
>> print report
>>
>> --
>> 2.1.4
>>
>>
>>
>>
>> --
>> This mail was scanned by BitDefender
>> For more information please visit http://www.bitdefender.com
>>
>> _______________________________________________
>> Fuego mailing list
>> Fuego@lists.linuxfoundation.org
>> https://lists.linuxfoundation.org/mailman/listinfo/fuego
_______________________________________________
Fuego mailing list
Fuego@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/fuego
[-- Attachment #2: 0002-ftc-gen-report-Add-excel-formatter.patch --]
[-- Type: text/plain, Size: 4020 bytes --]
From 8897af09744cd6db04e2f78f519f598351b34974 Mon Sep 17 00:00:00 2001
From: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
Date: Fri, 2 Mar 2018 09:59:48 +0700
Subject: [PATCH 2/3] ftc: gen-report: Add excel formatter
Add a formatter for excel format. The report file is stored in
${report_dir}. Currently, We always use pts_set_style function
for making the size of column proper. In the future, several
other fields can be added to the report, we can disable using
the pts_set_style function if it is needed
Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
---
engine/scripts/ftc | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)
diff --git a/engine/scripts/ftc b/engine/scripts/ftc
index 0b99f94..e0ed13d 100755
--- a/engine/scripts/ftc
+++ b/engine/scripts/ftc
@@ -2077,6 +2077,69 @@ def gen_pdf_report(header_data, report_data, report_dir):
elements.append(table)
doc.build(elements, onFirstPage=add_page_number, onLaterPages=add_page_number)
+# support generating the excel report format
+
+# adjust column width size
+# the size of data in fields and header_fields is quite small,
+# so, always use pts_set_style now
+def pts_set_style(ws):
+ dims ={}
+ for row in ws.rows:
+ for cell in row:
+ if cell.value:
+ dims[cell.column] = max((dims.get(cell.column, 0), len(str(cell.value)) + 2))
+ for col, value in dims.items():
+ ws.column_dimensions[col].width = value
+
+# return number to Excel-style column name
+def excel_column_name(n):
+ name = ""
+ while n > 0:
+ n, r = divmod (n - 1, 26)
+ name = chr(r + ord('A')) + name
+ return name
+
+def gen_excel_report(header_data, report_data, report_dir):
+ from openpyxl import Workbook
+ from openpyxl.style import Fill, Color
+
+ # create an excel file and add worksheets
+ workbook = Workbook()
+ header_sheet = workbook.create_sheet(title="Header")
+ data_sheet = workbook.create_sheet(title="Data")
+
+ # generate header
+ header_sheet.append(["Fuego Test Report"])
+ for field,val_str in header_data:
+ header_sheet.append(["%s: %s" % (field, val_str)])
+ # in future, if we don't want this, use a flag for checking using pts_set_style
+ pts_set_style(header_sheet)
+
+ # generate lines for this report
+ for item in report_data:
+ data_sheet.append(item)
+ # in future, we can disable this by using a flag
+ pts_set_style(data_sheet)
+
+ # format header row to sheet
+ head_fill = Fill()
+ head_fill.start_color = Color('FFC0C0C0')
+ head_fill.end_color = Color('FFC0C0C0')
+ head_fill.fill_type = Fill.FILL_SOLID
+ for j in range(0, data_sheet.get_highest_column()):
+ data_sheet.cell(row = 0, column = j).style.fill = head_fill
+
+ # add auto filter
+ data_sheet.auto_filter = "A1:" + excel_column_name(data_sheet.get_highest_column()) + str(data_sheet.get_highest_row())
+
+ # if we have added sheets, remove the default one ("Sheet")
+ sheets = workbook.get_sheet_names()
+ if len(sheets) > 1:
+ workbook.remove_sheet(workbook.get_sheet_by_name("Sheet"))
+
+ # save the report
+ workbook.save(report_dir + "report.xlsx")
+
# generate a report from run results
def do_gen_report(conf, options):
global quiet, verbose
@@ -2098,7 +2161,7 @@ def do_gen_report(conf, options):
fmt="txt"
if "--format" in options:
fmt = options[options.index("--format")+1]
- if fmt not in ["txt","html","pdf"]:
+ if fmt not in ["txt","html","pdf","excel"]:
error_out("Unsupported format '%s' specified" % fmt)
if "--layout" in options:
@@ -2129,6 +2192,9 @@ def do_gen_report(conf, options):
if fmt=="pdf":
gen_pdf_report(header_data, report_data, report_dir)
sys.exit(0)
+ if fmt=="excel":
+ gen_excel_report(header_data, report_data, report_dir)
+ sys.exit(0)
print report
--
2.1.4
[-- Attachment #3: Bitdefender.txt --]
[-- Type: text/plain, Size: 102 bytes --]
--
This mail was scanned by BitDefender
For more information please visit http://www.bitdefender.com
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Fuego] [PATCH 2/3] ftc: gen-report: Add excel formatter
2018-03-08 2:49 ` Hoang Van Tuyen
@ 2018-03-08 18:39 ` Tim.Bird
0 siblings, 0 replies; 4+ messages in thread
From: Tim.Bird @ 2018-03-08 18:39 UTC (permalink / raw)
To: tuyen.hoangvan, fuego
Very nice.
Thanks!
Applied.
-- Tim
> -----Original Message-----
> From: Hoang Van Tuyen
> I re-send the patch as an attachment.
>
>
> On 3/8/2018 6:06 AM, Tim.Bird@sony.com wrote:
> > Another problem with word wrapping.
> >
> > Possibly this is due to your wrap margin settings (or column
> > width settings) in your e-mail client.
> > -- Tim
> >
> >> -----Original Message-----
> >> From: fuego-bounces@lists.linuxfoundation.org [mailto:fuego-
> >> bounces@lists.linuxfoundation.org] On Behalf Of Hoang Van Tuyen
> >> Sent: Thursday, March 01, 2018 7:36 PM
> >> To: fuego@lists.linuxfoundation.org
> >> Subject: [Fuego] [PATCH 2/3] ftc: gen-report: Add excel formatter
> >>
> >> Add a formatter for excel format. The report file is stored in
> >> ${report_dir}. Currently, We always use pts_set_style function
> >> for making the size of column proper. In the future, several
> >> other fields can be added to the report, we can disable using
> >> the pts_set_style function if it is needed
> >>
> >> Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
> >> ---
> >> engine/scripts/ftc | 68
> >> +++++++++++++++++++++++++++++++++++++++++++++++++++++-
> >> 1 file changed, 67 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
> >> index 0b99f94..e0ed13d 100755
> >> --- a/engine/scripts/ftc
> >> +++ b/engine/scripts/ftc
> >> @@ -2077,6 +2077,69 @@ def gen_pdf_report(header_data,
> report_data,
> >> report_dir):
> >> elements.append(table)
> >> doc.build(elements, onFirstPage=add_page_number,
> >> onLaterPages=add_page_number)
> >>
> >> +# support generating the excel report format
> >> +
> >> +# adjust column width size
> >> +# the size of data in fields and header_fields is quite small,
> >> +# so, always use pts_set_style now
> >> +def pts_set_style(ws):
> >> + dims ={}
> >> + for row in ws.rows:
> >> + for cell in row:
> >> + if cell.value:
> >> + dims[cell.column] = max((dims.get(cell.column, 0),
> >> len(str(cell.value)) + 2))
> >> + for col, value in dims.items():
> >> + ws.column_dimensions[col].width = value
> >> +
> >> +# return number to Excel-style column name
> >> +def excel_column_name(n):
> >> + name = ""
> >> + while n > 0:
> >> + n, r = divmod (n - 1, 26)
> >> + name = chr(r + ord('A')) + name
> >> + return name
> >> +
> >> +def gen_excel_report(header_data, report_data, report_dir):
> >> + from openpyxl import Workbook
> >> + from openpyxl.style import Fill, Color
> >> +
> >> + # create an excel file and add worksheets
> >> + workbook = Workbook()
> >> + header_sheet = workbook.create_sheet(title="Header")
> >> + data_sheet = workbook.create_sheet(title="Data")
> >> +
> >> + # generate header
> >> + header_sheet.append(["Fuego Test Report"])
> >> + for field,val_str in header_data:
> >> + header_sheet.append(["%s: %s" % (field, val_str)])
> >> + # in future, if we don't want this, use a flag for checking using
> >> pts_set_style
> >> + pts_set_style(header_sheet)
> >> +
> >> + # generate lines for this report
> >> + for item in report_data:
> >> + data_sheet.append(item)
> >> + # in future, we can disable this by using a flag
> >> + pts_set_style(data_sheet)
> >> +
> >> + # format header row to sheet
> >> + head_fill = Fill()
> >> + head_fill.start_color = Color('FFC0C0C0')
> >> + head_fill.end_color = Color('FFC0C0C0')
> >> + head_fill.fill_type = Fill.FILL_SOLID
> >> + for j in range(0, data_sheet.get_highest_column()):
> >> + data_sheet.cell(row = 0, column = j).style.fill = head_fill
> >> +
> >> + # add auto filter
> >> + data_sheet.auto_filter = "A1:" +
> >> excel_column_name(data_sheet.get_highest_column()) +
> >> str(data_sheet.get_highest_row())
> >> +
> >> + # if we have added sheets, remove the default one ("Sheet")
> >> + sheets = workbook.get_sheet_names()
> >> + if len(sheets) > 1:
> >> + workbook.remove_sheet(workbook.get_sheet_by_name("Sheet"))
> >> +
> >> + # save the report
> >> + workbook.save(report_dir + "report.xlsx")
> >> +
> >> # generate a report from run results
> >> def do_gen_report(conf, options):
> >> global quiet, verbose
> >> @@ -2098,7 +2161,7 @@ def do_gen_report(conf, options):
> >> fmt="txt"
> >> if "--format" in options:
> >> fmt = options[options.index("--format")+1]
> >> - if fmt not in ["txt","html","pdf"]:
> >> + if fmt not in ["txt","html","pdf","excel"]:
> >> error_out("Unsupported format '%s' specified" % fmt)
> >>
> >> if "--layout" in options:
> >> @@ -2129,6 +2192,9 @@ def do_gen_report(conf, options):
> >> if fmt=="pdf":
> >> gen_pdf_report(header_data, report_data, report_dir)
> >> sys.exit(0)
> >> + if fmt=="excel":
> >> + gen_excel_report(header_data, report_data, report_dir)
> >> + sys.exit(0)
> >>
> >> print report
> >>
> >> --
> >> 2.1.4
> >>
> >>
> >>
> >>
> >> --
> >> This mail was scanned by BitDefender
> >> For more information please visit http://www.bitdefender.com
> >>
> >> _______________________________________________
> >> Fuego mailing list
> >> Fuego@lists.linuxfoundation.org
> >> https://lists.linuxfoundation.org/mailman/listinfo/fuego
>
> _______________________________________________
> Fuego mailing list
> Fuego@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-03-08 18:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-02 3:36 [Fuego] [PATCH 2/3] ftc: gen-report: Add excel formatter Hoang Van Tuyen
2018-03-07 23:06 ` Tim.Bird
2018-03-08 2:49 ` Hoang Van Tuyen
2018-03-08 18:39 ` Tim.Bird
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.