我似乎無法在Excel表格中寫入任何值。我同時打開兩個文件。我想將文件1中的值複製到文件2.它給出了錯誤Python Openpyxl寫入單元格
File
"C:\Python34\lib\site-packages\openpyxl\writer\dump_worksheet.py", line 214, in removed_method
raise NotImplementedError
只有寫入部分的行出現錯誤。功能代碼如下
def data_input(size):
from openpyxl import load_workbook
wb1 = load_workbook('150318 load matching_Storage_v4.xlsm',data_only=True)
wb1s1 = wb1.get_sheet_by_name('Home load options')
from openpyxl import Workbook
wb2 = Workbook('Data',write_only=True)
wb2s1 = wb2.create_sheet(0)
wb2s1.title = "Consumption"
wb2s1.cell(row = 1, column = 1).value = 4 - this line gives the error
#what i have to write but block yet to test if i can write at all
'''i = 0
r = 0
while i < 8760:
d = wb2s1.cell(row = r, column = 1)
d.value = i
i = i + 0.25
r += 1'''
for i in range(4,35040):
cell_value1 = wb1s1.cell(row = i, column = (12+size)).value
print(cell_value1)
# cell_value1 = wb2s1.cell(row = i-3, column = 1)
wb2.save('Data.xlsx')
我在文檔中嘗試了所有不同的方法,但到目前爲止沒有任何工作。
請大家幫忙。
謝謝
我應該使用append方法? – Abdur