目录结构:
xlsx文件格式:
xlsxToLua.py如下:
import xlrd
import os
def toLua():
pwd = "./"
fileList = list(os.listdir(pwd)) # 列出文件夹下所有的目录与文件
for file in fileList:
if file.find(".xlsx") > 0 and ( file.find("~") < 0 ):
fileName = file[:file.find(".xlsx")]
print("开始转化:", fileName)
filepwd = pwd + "/" + file
with xlrd.open_workbook(filepwd) as workbook:
sheet1 = workbook.sheet_by_index(0) # sheet索引从0开始
nrows = sheet1.nrows