TenTags Playground

Edit CSV style and data rules in real-time, preview compiled HTML, and publish templates to the gallery.

← Browse Template Gallery
✨ AI LAYOUT GENERATOR Describe your table layout in plain text and AI will generate TenTags Style & Data CSVs instantly.
🪄
🎨 Style CSV STYLE FORMULA
0 lines
📊 Data CSV DATA FORMULA
0 lines
🐍 Python Backend Example: Dynamic DB Export with tentags.serialize & render
import sqlite3
import tentags

# 1. Query records from database
conn = sqlite3.connect("company.db")
cursor = conn.cursor()
rows = cursor.execute("SELECT product, revenue_q1, revenue_q2, status FROM sales_reports").fetchall()
conn.close()

# 2. Build Python matrices for Data and Style (utilizing tag spanning across cells)
data_matrix = [
    ["Executive Financial Summary", "", "", ""],
    ["Product Line", "Q1 Revenue", "Q2 Revenue", "Performance"],
]

style_matrix = [
    ["
", "", "", ""], ["", "
", "
", "
"], ] for product, q1, q2, status in rows: data_matrix.append([product, f'"${q1:,.0f}"', f'"${q2:,.0f}"', status]) status_style = ( "
" if status == "Excellent" else "
" ) style_matrix.append([ "", "", "", status_style ]) # 3. Serialize Python matrices into TenTags DSL blocks via tentags.serialize rows = len(data_matrix) cols = len(data_matrix[0]) if data_matrix else 0 preamble = tentags.serialize.preamble( rows=rows, cols=cols, border_color="#cbd5e1", border_style="solid", cell_height=32 ) style = tentags.serialize.style(style_matrix) data = tentags.serialize.data(data_matrix) # 4. Render directly to HTML string or compile & export to PDF/Excel html_output = tentags.render(preamble, style, data) # Export to PDF and XLSX: model = tentags.compile(preamble, style, data) tentags.render_pdf(model, "financial_report.pdf") tentags.render_xlsx(model, "financial_report.xlsx")