将Excel表格数据转换成XML格式文件
读取Excel文件,将其表中的列名作为属性名,单元格值作为属性值,转换成xml格式文件。代码如下:
import xml.etree.ElementTree as ET
import xlrd
#read data from a xlsx'file and assign them to a list
ExcelFileName = 'F:\\2019sh\\m8\\data\\t1.xlsx'
workbook = xlrd.open_workbook(ExcelFileName)
worksheet = workbook.sheet_by_name("Sheet1")
num_rows = worksheet.nrows
num_cols = worksheet.ncols
result_data = []
for curr_row in range(0, num_rows, 1):
row_data = []
for cur