diff --git a/Automation_Excel/README.md b/Automation_Excel/README.md new file mode 100644 index 0000000..6c9a133 --- /dev/null +++ b/Automation_Excel/README.md @@ -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 +``` + + + + diff --git a/Automation_Excel/automation.py b/Automation_Excel/automation.py new file mode 100644 index 0000000..8136e4c --- /dev/null +++ b/Automation_Excel/automation.py @@ -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) \ No newline at end of file