'Python (OpenPyxl) openpyxl not write anything
Code :
wb = Workbook() sdwbb = load_workbook(sdpath) filename = os.path.basename(sdpath) bulan = "September" try: sdp = sdwbb[bulan] except: sdwbb.create_sheet(bulan) wb.save(filename) time.sleep(0.5) sdp = sdwbb[bulan] cell_one = sdp['F1'] cell_one.value = 'test' sdwbb.save(filename)
for your information I doesn't get any error but its doesn't write anything cell f1 sheet September
what I trying to do is to write on specific workbook ,sheet ,and cell
Solution 1:[1]
This is my code to write "test" in cel F1 (in the current sheet) in the file test.xlxs in the same folder:
from openpyxl import Workbook, load_workbook
wb = load_workbook("test.xlsx")
ws = wb.active
ws["F1"] = "test"
wb.save("test.xlsx")
print("done")
It's as easy as that :).
Also, you should devenitly check out the documentation of openpyxl: https://openpyxl.readthedocs.io/en/stable/tutorial.html#create-a-workbook
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tuurtje11 |
