Operating environment:
Python version: Python2.7.15
Third-party libraries: pywin32
Excel Version: Excel2016
1. Install Python2.7.15
1) Download the Python Package
Enter Python's official website: www.python.org , open the page as follows:
Select Downloads-> All releases-> Download Python 2.7.15, then wait for the download to complete
2) install Python
Go to the download directory, double-click the installation package, has been hit next to (If you do not want to modify the installation path)
After installation is complete open DOS window (Win + R, press the Enter cmd input), the input command python2, python verify whether the installation is successful, as shown below:
Python installation has been completed so far
Note: The computer I installed two versions of python, so need to add the version number to distinguish with the corresponding command
2. Install pywin32 library
pywin32 installation method:
Installation: enter the command pip2 install pywin32
Note: Because my computer to install two versions of Python, so use pip2
3. Complete the Conversion
Test file: easy_excel.py , operate.py , Test.xls
Operation method: The above-mentioned document is placed in the same folder, and then open the Dos window, enter the directory corresponding to the folder, to enter python2 operate.py
Example: I put the file in E: ExcelToXML operate under the directory \
Generated xml file name: file name + table
Then the xml file to import testlink
Caution:
1) installed pywin32 can test whether you can open Excel tables, test code as follows
import win32com.client
xlsApp = win32com.client.Dispatch('Excel.Application')
xlsApp.Workbooks.Open(r'F:/test.xls')
2)注意Excel版本要大于2007,在运行脚本之前将后缀名修改为.xls