domdf_spreadsheet_tools
¶
Table of Contents
Tools for creating and formatting spreadsheets with Python and OpenPyXL
-
domdf_spreadsheet_tools.
append_to_xlsx
(csv_input_file, xlsx_output_file, sheet_title=None, separator=',', overwrite=False, use_io=False, toFloats=False)[source]¶ Add CSV file to xlsx file as a new worksheet
- Parameters
csv_input_file (str or pathlib.Path or os.PathLike) – filepath of CSV file to
xlsx_output_file (str or pathlib.Path or os.PathLike) – filepath of xlsx file
sheet_title (str, optional) – Title of sheet to append. Default is the value of
csv_input_file
separator (str, optional) – Separator for reading CSV file. Default
,
overwrite (bool, optional) – Whether to overwrite the xlsx output file (i.e. create a new file containing just the new sheet). Default
False
use_io (bool, optional) – Whether to use the io module. Default
False
toFloats (bool, optional) – Whether to read strings with thousand separators as floats. Default
False
- Return type
None
-
domdf_spreadsheet_tools.
format_header
(ws, alignment_list, start_row=1, end_row=1)[source]¶ Format the alignment of the header rows of a worksheet
- Parameters
ws (openpyxl.worksheet.worksheet.Worksheet) – The worksheet to format
alignment_list (
Dict
[str
,str
]) – dictionary of alignments (left, right, center) for each column letterstart_row (int, optional) – The row to start formatting on. Default
1
end_row (int, optional) – The row to end formatting on. Default
1
-
domdf_spreadsheet_tools.
format_sheet
(ws, number_format_list=None, width_list=None, alignment_list=None)[source]¶ Format columns of an xlsx worksheet
- Parameters
ws (openpyxl.worksheet.worksheet.Worksheet) – The worksheet to format
number_format_list (
Optional
[Dict
[str
,str
]]) – dictionary of number format strings for each column letterwidth_list (
Optional
[Dict
[str
,float
]]) – dictionary of widths for each column letteralignment_list (
Optional
[Dict
[str
,str
]]) – dictionary of alignments (left
,right
, orcenter
) for each column letter