tksheet
tksheet copied to clipboard
how load data from excel?
I need to insert pandas dataframe to tksheet, if I use parameter "headear=0", the dataframe header will not show in tksheet.
This will take some trouble to me, in order to get the header I need to contact two dataframe or save and reload the excel useparameter "headear=None" , see the code in below.
But normally this settings is helpful for more data cleansing . I wonder If you could make a change for this, thanks very much.
self.data = pd.read_excel(self.path, engine="openpyxl", header=0, keep_default_na=False)
self.data = self.data[self.data['Status(状态)'] == status]
df5 = pd.read_excel(self.path, engine="openpyxl", header=None, nrows=1, keep_default_na=False) # 读取表头
df5.columns = ['Production No', 'Material no(物料号)', 'miss date', 'Type(类型)', 'Order qty(数量)', 'start(开始时间)', '预计
入库日期', 'Status(状态)', 'fin(完成时间)']
self.data = pd.concat([df5, self.data], axis=0) # Merge header
self.sheet = Sheet(self.frm1,
page_up_down_select_row=True,
expand_sheet_if_paste_too_big=True,
# empty_vertical = 0,
column_width=110,
startup_select=(0, 0, "cells"), # 起始选定单元格 rows行
data= self.data.values.tolist(),
height=800, # height and width arguments are optional
width=2000 # For full startup arguments see DOCUMENTATION.md
)
Finally,I save the data to excel and use xlwings print the table.
This issue can be closed now,thanks.
solution: use self.data = self.data.T.reset_index().T.values.tolist() can keep column information in the list .