Я пытался просмотреть руководство, а также провести некоторые исследования, но, похоже, так и не понял, что делаю неправильно. Ниже приведен код, который я использую
Код: Выделить всё
import openpyxl as opxl
#Opening the destination excel file
sourceFile = "C:\\ForTesting\\sourceFile.xlsx"
sourceworkbook = opxl.load_workbook(sourceFile)
sourceworksheet = sourceworkbook.worksheets[0]
#Opening the destination excel file
destinationFile = "C:\\ForTesting\\destinationFile.xlsx"
desinationworkbook = opxl.load_workbook(destinationFile)
destinationworksheet = desinationworkbook.active
# calculate total number of rows and
# columns in source excel file
maximum_row = sourceworksheet.max_row
maximum_column = sourceworksheet.max_column
# copying the cell values from source
# excel file to destination excel file
for i in range (1, maximum_row + 1):
for j in range (1, maximum_column + 1):
#reading the cell value from source excel file
c = sourceworksheet.cell(row = i, column = j)
#writing the value read from the source file to destination file
destinationworksheet.cell(row = i, column = j).value = c.value
#Save the destination excel file
sourceworkbook.save(str(destinationFile))
print("The File has been saved successfully")
Подробнее здесь: https://stackoverflow.com/questions/687 ... er-content