Home > other >  Xlwings couldn't open the excel error
Xlwings couldn't open the excel error

Time:11-20

Recent colleagues to do large quantities of the same format excel processing, want to use python to try to deal with, but a simple open file read error, speechless,
Ask you to help ah,

Program is very simple template is online teaching:
The import xlwings as xw
App=xw. App (visible=True, add_book=False)
Wb=app. Books. The open (r 'F: \ test. XLSX')
# wb is the new workbook (workbook), the following is the assignment of wb sheet1 A1 cell
Wb. Sheets [' sheet1]. Range (" A1 "). Value='https://bbs.csdn.net/topics/is short'
Wb. The save ()
Wb. Close ()
App. The quit ()

F: \ test. XLSX file and built, with excel can normal open,
Test run error:

Traceback (the most recent call last) :
File "D: \ python \ lib \ site - packages \ xlwings \ _xlwindows py", line 447, in __call__
Return the Book (xl=self. Xl (name_or_index))
File "D: \ python \ lib \ site - packages \ xlwings \ _xlwindows py", line 155, in __call__
V=self. _inner (* args, * * kwargs)
The File "D: \ python \ lib \ site - packages \ win32com \ client \ dynamic py", line 197, in __call__
Return the self. _get_good_object_ (self) _oleobj_) Invoke (* allArgs), self. _olerepr_. DefaultDispatchName, None)
Pywintypes.com _error: (- 2147352567, 'accident,' and (0, None, None, None, 0, - 2147352565), None)

During handling of the above exception, another exception occurred:

Traceback (the most recent call last) :
File "D: \ python \ lib \ site - packages \ xlwings \ main py", line 2974, in the open
Impl=self. Impl (name)
File "D: \ python \ lib \ site - packages \ xlwings \ _xlwindows py", line 449, in __call__
Raise KeyError (name_or_index)
KeyError: 'test. XLSX'

During handling of the above exception, another exception occurred:

Traceback (the most recent call last) :
The File "F: \ open_excel. Py," the line 3, the in & lt; module>
Wb=app. Books. The open (r 'F: \ test. XLSX')
File "D: \ python \ lib \ site - packages \ xlwings \ main py", line 2980, in the open
Impl=self. Impl. Open (fullname, update_links read_only, format, password, write_res_password,
File "D: \ python \ lib \ site - packages \ xlwings \ _xlwindows py", line 465, in the open
Return the Book (xl=self. Xl. Open (fullname, update_links read_only, format, password, write_res_password,
File "D: \ python \ lib \ site - packages \ xlwings \ _xlwindows py", line 66, in __call__
V=self. __method (* args, * * kwargs)
The File "& lt; COMObject & lt; Unknown>" , line 5, in the Open
Pywintypes.com _error: (- 2147417851, 'server unexpected situation,, None, None)
[Finished in 23.7 s]

Don't know what the reason, it will take 23.7 s, and has confirmed that F: \ test XLSX did not open, not occupied,
But the reason for the error completely look not to understand,

CodePudding user response:

Try the openpyxl module

CodePudding user response:

Top, don't sink and no one knows how to solve it, or want to try xlwings,
Prev:filter
  • Related