问题
Here's the code I am using
excel = win32com.client.Dispatch('Excel.Application')
wb = excel.Workbooks.Open('myWorkbook.xlsx')
df = pd.DataFrame({'A':[1,2,3,4,5], 'B':[11,22,33,44,55], 'C':['a','b','c','d','e']})
wb.Sheets('Template').Copy(Before=None, After=wb.Sheets(wb.Sheets.count))
ws = wb.Sheets(wb.Sheets.count)
ws.Range(ws.cells(40,19), 40+len(df.index)-1, 19+len(df.columns)).Value = df.values
But I always receive the following error: ValueError: ndarray is not C-contiguous
来源:https://stackoverflow.com/questions/61743292/can-we-copy-a-dataframe-with-rows-and-cols-1-into-an-excel-sheet