I've built budget.xlsx, but I haven't recalculated it. LibreOffice isn't installed here, so Excel will calculate the formulas when you open the file. The script that generates it is build_xlsx.py, in the same folder.
What's in it
- Inputs sheet: the assumptions are in yellow cells and labelled "Sample". They are monthly income 4,500, rent 1,400, food 600, transport 250, utilities 200 and a savings goal of 15%.
- Budget sheet:
- Categories: rent, food, transport and utilities. Each amount is a formula pointing at the Inputs sheet (for example
=Inputs!B5), and each has a "% of income" column. - Totals: a total spent row (
=SUM(B4:B7)), income, and the remaining amount (income minus total spent). - Savings check: it compares the remaining amount with income × savings goal %. It shows "On track - surplus of …" or "Short by …".
- Categories: rent, food, transport and utilities. Each amount is a formula pointing at the Inputs sheet (for example
- Chart: a bar chart of spending by category, titled as sample, next to the table.
What I checked
- I reopened the saved file and confirmed there are two sheets, one chart, and no hard-coded numbers on the Budget sheet. Every amount and total is a formula.
- I read each formula's cell references by hand and they point at the right inputs.
- Working it out by hand with the sample numbers, total spent is 2,450, remaining is 2,050, and the savings goal is 675. The check should therefore read "On track - surplus of 1,375.00".
Not checked
- No recalculation, so I haven't seen the computed values or confirmed the chart renders correctly.
- If a number looks off when you open it, tell me.
Your call: the savings goal isn't counted as a spending category. It's only compared against what's left over. I can add it as a category if you'd rather see it in the total and the chart.
Test run: a sample household budget built with openpyxl in a temporary folder. The run was allowed to write files and run python3 only. The formulas were inspected by re-opening the file and by hand calculation, but not recalculated, because LibreOffice was not installed. Excel calculates them on opening. All numbers are sample.
Qué hace
Escribe y ejecuta un script de Python que crea o modifica un libro para que se comporte como una hoja de cálculo real. Los cálculos son fórmulas que hacen referencia a una hoja de entradas etiquetada o a rangos con nombre, no números incrustados en fórmulas ni valores pegados. Configura el formato de los encabezados, los formatos numéricos, los anchos, la inmovilización de paneles, la validación de datos, el formato condicional y los gráficos. Al editar un archivo existente, primero enumera las hojas, las fórmulas y los rangos con nombre, cambia solo las celdas solicitadas, advierte de lo que openpyxl puede perder al guardar (tablas dinámicas, segmentaciones de datos, algunos formatos) y guarda el resultado con un nombre nuevo. También puede auditar una hoja para detectar valores de error, números almacenados como texto, números escritos directamente en las fórmulas y rangos que no llegan a cubrir todos los datos. openpyxl no puede recalcular, así que indica si las fórmulas se recalcularon o solo se inspeccionaron.
Salida
El archivo .xlsx, el script, un informe de verificación con lo que se calculó y lo que no, y los supuestos que hay que confirmar.
Ideal para
Presupuestos, hojas de seguimiento y libros de informes generados o corregidos a partir de datos, y auditorías rápidas de una hoja de cálculo que muestra errores.
Riesgo medio: solo instrucciones, sin scripts propios, pero escribe y ejecuta Python que crea archivos en tu carpeta de trabajo y puede sugerir instalar openpyxl en un entorno virtual. Nunca sobrescribe tu original, no crea macros ni añade enlaces externos. Se probó una vez en una carpeta temporal con números de ejemplo: creó un presupuesto de dos hojas con fórmulas y un gráfico; las fórmulas se inspeccionaron y se comprobaron manualmente, pero no se recalcularon porque faltaba LibreOffice. Excel las calcula al abrirlas. No dependas de ella para decisiones financieras o fiscales. Original de AIBars (MIT).