Oct-17-2017, 07:39 PM
I have the following code to efficiently try to read older .xls files and save them as .xlsx. However, it keeps cutting off the first row and the last column of my data that I'm trying to copy into the new workbook. Any ideas as to how the indexing needs to be fixed to correct this problem?
-----------
-----------
import xlrd from openpyxl.workbook import Workbook as openpyxlWorkbook from Tkinter import * import Tkinter, tkFileDialog import os from openpyxl import Workbook workbook=Workbook() root=Tk() filepath=tkFileDialog.askopenfilenames() for i in filepath: file, path=os.path.split(i) wb=xlrd.open_workbook(i) for k in range(0, wb.nsheets): xlsSheet=wb.sheet_by_index(k) sheet=workbook.active if k==0 else workbook.create_sheet() sheet.title=xlsSheet.name for row in xrange(1, xlsSheet.nrows): for col in xrange(1, xlsSheet.ncols): sheet.cell(row=row, column=col).value=xlsSheet.cell(row, col).value