This Python script generates a sales report in Excel format using the openpyxl
library. The user is prompted to input the month, product categories, and corresponding sales data. The script then creates an Excel workbook with a bar chart visualizing the sales data and includes sum formulas for each category.
-
User Input:
- The script prompts the user to input the month, product categories (comma-separated), and sales data for each category.
-
Excel Workbook and Chart:
- A new Excel workbook is created using the
openpyxl
library. - Sales data is input into the sheet, and a bar chart is generated using the entered information.
- A new Excel workbook is created using the
-
Sum Formulas:
- Sum formulas are automatically generated for each category to calculate the total sales.
-
Formatting:
- The script adds formatting to the Excel sheet, including a title and font styling.
-
Save Workbook:
- The generated workbook is saved in the same directory as the script with a filename based on the entered month.
- Run the script using a Python interpreter.
- Enter the month when prompted.
- Enter product categories (comma-separated) when prompted.
- Enter sales data for each category.
- The script will generate an Excel workbook with a bar chart and sum formulas.
- The workbook is saved in the same directory as the script with a filename based on the entered month.
Note:
- Ensure you have the
openpyxl
library installed (pip install openpyxl
). - Customize the script as needed for specific reporting requirements.
- Use responsibly and consider legal and ethical considerations when automating data input.
Feel free to adapt and extend this script for your specific reporting needs.