Skip to content

Commit

Permalink
improved api
Browse files Browse the repository at this point in the history
  • Loading branch information
John Bogaardt committed Dec 21, 2019
1 parent 4afb2b3 commit d136784
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion xlcompose/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def to_excel(self):
workbook_path : str
The target path and filename of the Excel document
"""
self.exhibits = copy.deepcopy(self.exhibits)
if self.exhibits.__class__.__name__ != 'Tabs':
self.exhibits = Tabs(('sheet1', self.exhibits))
for sheet in self.exhibits:
Expand Down Expand Up @@ -389,10 +390,14 @@ def __init__(self, data, formats=None,
self.column_widths = column_widths
self.height = data.shape[0] + self.col_nums + self.header
self.width = data.shape[1] + self.index
if type(title) is str:
title = [title]
if title is None or title == []:
title = None
else:
self.height = self.height + len(title)
if type(title) is list:
title = Title(title)
self.title = title
if header_formats is not None:
self.header_formats.update(header_formats)
Expand Down Expand Up @@ -443,7 +448,12 @@ def format_validation(self, formats):
'datetime64[ns]': {'num_format': 'yyyy-mm-dd hh:mm', 'align': 'center'},
'object': {'align': 'left'},
}
cols = self.data.dtypes.reset_index().drop_duplicates().set_index('index').iloc[:,0].astype(str)
if self.data.columns.name is not None:
idx = self.data.index.to_frame().dtypes
idx.index = [self.data.columns.name]
else:
idx = pd.Series()
cols = self.data.dtypes.append(idx)
self.formats = {
k: base_formats.get(v, base_formats['object'])
for k, v in dict(cols).items()
Expand Down

0 comments on commit d136784

Please sign in to comment.