Skip to content

Commit c8752ef

Browse files
authored
Update index.rst
1 parent f3cf8fa commit c8752ef

File tree

1 file changed

+108
-10
lines changed

1 file changed

+108
-10
lines changed

development-tools/index.rst

Lines changed: 108 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,111 @@
1-
.. _development-tools:
1+
import openpyxl
2+
from openpyxl import Workbook
3+
from openpyxl.styles import Font, Alignment, Border, Side, PatternFill
24

3-
=================
4-
Development tools
5-
=================
5+
# Crear libro
6+
wb = Workbook()
67

7-
.. toctree::
8-
:maxdepth: 5
8+
# === Estilos ===
9+
bold = Font(bold=True)
10+
center = Alignment(horizontal="center", vertical="center")
11+
thin_border = Border(
12+
left=Side(style="thin"),
13+
right=Side(style="thin"),
14+
top=Side(style="thin"),
15+
bottom=Side(style="thin")
16+
)
17+
fill_header = PatternFill(start_color="D9E1F2", end_color="D9E1F2", fill_type="solid")
918

10-
clinic/index
11-
gdb
12-
clang
13-
warnings
19+
# --- Hoja 1: Libro Diario ---
20+
ws1 = wb.active
21+
ws1.title = "Libro Diario"
22+
23+
# Encabezados
24+
headers = ["Fecha", "Cuenta", "Débito", "Crédito"]
25+
ws1.append(headers)
26+
27+
# Aplicar formato a encabezados
28+
for col in range(1, 5):
29+
cell = ws1.cell(row=1, column=col)
30+
cell.font = bold
31+
cell.alignment = center
32+
cell.fill = fill_header
33+
cell.border = thin_border
34+
35+
# Transacciones
36+
transacciones = [
37+
("01/10/2025", "Caja", 1500, ""),
38+
("", "Capital Social", "", 1500),
39+
("", "SUMAS IGUALES", 1500, 1500),
40+
41+
("02/10/2025", "Bancos", 800, ""),
42+
("", "Caja", "", 800),
43+
("", "SUMAS IGUALES", 800, 800),
44+
45+
("03/10/2025", "Inventario Mercancías", 1200, ""),
46+
("", "Proveedores", "", 1200),
47+
("", "SUMAS IGUALES", 1200, 1200),
48+
49+
("04/10/2025", "Proveedores", 500, ""),
50+
("", "Bancos", "", 500),
51+
("", "SUMAS IGUALES", 500, 500),
52+
53+
("05/10/2025", "Gastos de Administración", 300, ""),
54+
("", "Caja", "", 300),
55+
("", "SUMAS IGUALES", 300, 300),
56+
57+
("", "TOTALES GENERALES", 4300, 4300),
58+
]
59+
60+
for fila in transacciones:
61+
ws1.append(fila)
62+
63+
# Formato general
64+
for row in ws1.iter_rows(min_row=2, max_row=ws1.max_row, min_col=1, max_col=4):
65+
for cell in row:
66+
cell.border = thin_border
67+
if cell.column in (3, 4): # Débito y Crédito
68+
cell.alignment = Alignment(horizontal="right")
69+
else:
70+
cell.alignment = Alignment(horizontal="left")
71+
72+
# Ajustar ancho de columnas
73+
col_widths = [12, 30, 15, 15]
74+
for i, width in enumerate(col_widths, 1):
75+
ws1.column_dimensions[openpyxl.utils.get_column_letter(i)].width = width
76+
77+
78+
# --- Hoja 2: Balance de Prueba ---
79+
ws2 = wb.create_sheet(title="Balance de Prueba")
80+
81+
headers2 = ["Cuenta", "Débito", "Crédito"]
82+
ws2.append(headers2)
83+
84+
for col in range(1, 4):
85+
cell = ws2.cell(row=1, column=col)
86+
cell.font = bold
87+
cell.alignment = center
88+
cell.fill = fill_header
89+
cell.border = thin_border
90+
91+
balance = [
92+
("Caja", 700, ""),
93+
("Bancos", 300, ""),
94+
("Inventario Mercancías", 1200, ""),
95+
("Proveedores", "", 700),
96+
("Gastos de Administración", 300, ""),
97+
("Capital Social", "", 1500),
98+
("TOTALES", 2500, 2500),
99+
]
100+
101+
for fila in balance:
102+
ws2.append(fila)
103+
104+
# Formato general hoja 2
105+
for row in ws2.iter_rows(min_row=2, max_row=ws2.max_row, min_col=1, max_col=3):
106+
for cell in row:
107+
cell.border = thin_border
108+
if cell.column in (2, 3):
109+
cell.alignment = Alignment(horizontal="right")
110+
else:
111+
cell.alignment = Alignment(

0 commit comments

Comments
 (0)