Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Automation_Excel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# Automation in Excel Files

A small Python application will take an Excel file (.xlsx) as input and will update specific rows and columns, then add a graph to it and save it into a new file.

## Installation

Install the openpyxl



```bash
pip install openpyxl
```




31 changes: 31 additions & 0 deletions Automation_Excel/automation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from typing import ValuesView
import openpyxl as xl
from openpyxl.chart import BarChart, Reference

def processing(filename):
wb = xl.load_workbook(filename)
sheet = wb['Sheet1']
cell = sheet.cell(1, 2)
print(sheet.max_row)
for i in range(2, sheet.max_row+1):
print(sheet.cell(i, 3).value)
new_cell = sheet.cell(1, 4)
new_cell.value = "new cell"
for i in range(2, 5):
new_values = sheet.cell(i, 4)
new_values.value = int(input(""))
Values = Reference(
sheet,
min_row = 1,
max_row = 5,
min_col = 1,
max_col = 5
)
chart = BarChart()
chart.add_data(Values)
sheet.add_chart(chart, 'a5')
wb.save(filename)


filename = input("enter the name of the file: ")
processing(filename)