pip install openpyxl
from openpyxl import Workbook wb = Workbook() ws = wb.active ws['B2'] = 25 path = 'valami.xlsx' wb.save(path)
from openpyxl import load_workbook path = 'valami.xlsx' wb = load_workbook(path) print(wb.sheetnames) wb.save(path)
from openpyxl import load_workbook path = 'valami.xlsx' wb = load_workbook(path) sheet = wb.worksheets[0] sheet.cell(row = 1, column = 1).value = 35 sheet.cell(row = 2, column = 1).value = 42 sheet.cell(row = 3, column = 1).value = 16 sheet.cell(row = 4, column = 1).value = '=sum(a1:a3)' wb.save(path)
from openpyxl import load_workbook path = 'valami.xlsx' wb = load_workbook(path) sheet = wb.worksheets[0] sheet['a1'] = 25 sheet['a2'] = 42 sheet['a3'] = 15 sheet['a4'] = '=sum(a1:a3)' wb.save(path)
from openpyxl import load_workbook path = 'valami.xlsx' wb = load_workbook(path) sheet = wb.active cell = sheet.cell(row = 2, column = 2) print(cell.value)
from openpyxl import load_workbook path = 'valami.xlsx' wb = load_workbook(path) sheet = wb.worksheets[0] cell = sheet.cell(row = 2, column = 2) print(cell.value)