0
我在Excel中有要分割的數據。如何在Python中使用win32com分割Excel數據(3.6)
這裏是我的代碼
import win32com.client
excel = win32com.client.Dispatch("Excel.Application")
excel.Visible = True
wb = excel.Workbooks.Open('C:\\Users\\a\\Desktop\\bin256.xlsx')
ws = wb.ActiveSheet
input_number = ws.Range('U4:U15363')
number = [input_number[i:i+60] for i in range(0,len(input_number),60)]
但我得到這個錯誤:
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
number = [input_number[i:i+60] for i in range(0,len(input_number),60)]
File "<pyshell#13>", line 1, in <listcomp>
number = [input_number[i:i+60] for i in range(0,len(input_number),60)]
File "C:\Users\a\AppData\Local\Programs\Python\Python36-32\lib\site-packages\win32com\client\dynamic.py", line 256, in __getitem__
return self._get_good_object_(self._oleobj_.Invoke(dispid, LCID, invkind, 1, index))
TypeError: Objects of type 'slice' can not be converted to a COM VARIANT
我該如何解決呢?提前致謝。
沒有我打開Excel和讀取位於U(行)數據 – seokbin
我想分割數據,每60 – seokbin