在excel电子表格中,我将列宽和标题设置为所需的方式,并将f之后的每一列隐藏起来。例如,第1行:列a、b、c和e都向左对齐,列d居中,列f向右对齐。当使用我的代码写入excel时,它会重置列文本的对齐方式,使f之后的所有列可见,并重置我拥有的列宽。
df1 = pd.read_excel(path)
col1= df1['Job Number']
col2 = df1['Operator']
col3= df1['Program']
col4 = df1['QTY']
col5= df1['Part Number']
col6 = df1['Date']
A = pd.Series(entry1.get().upper())
B = pd.Series(entry2.get().upper())
C = pd.Series(entry3.get().upper())
D = pd.Series(entry4.get().upper())
E = pd.Series(entry5.get().upper())
#
col1 = col1.append(A)
col2 = col2.append(B)
col3 = col3.append(C)
col4 = col4.append(D)
col5 = col5.append(E)
df2 = pd.DataFrame({"Job Number":col1,'Operator':col2,"Program":col3,"QTY":col4, "Part Number":col5,"Date":col6})
df2.to_excel(path, index=False)```
暂无答案!
目前还没有任何答案,快来回答吧!