Generate Billing Statement

Generate an XLSX billing statement with a merged company header, subscription line items, overages, credits, and subtotal/tax/total formulas.

No credit card required — start with free trial credits

Who this is for

Subscription SaaS platforms use this recipe to generate monthly billing statements as XLSX for enterprise customers who need them for internal accounting and procurement. Define your charges, overages, and credits, and let formulas handle subtotals, tax, and totals automatically.

Request
curl -X POST https://api.iterationlayer.com/sheet-generation/v1/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "format": "xlsx",
    "styles": {
      "header": {
        "font_family": "Helvetica",
        "font_size_in_pt": 11,
        "is_bold": true,
        "background_color": "#4A148C",
        "font_color": "#FFFFFF"
      },
      "body": {
        "font_family": "Helvetica",
        "font_size_in_pt": 11,
        "font_color": "#333333"
      }
    },
    "sheets": [
      {
      "name": "Statement — March 2026",
      "columns": [
        {
          "name": "Date",
          "width": 14,
        },
        {
          "name": "Description",
          "width": 40,
        },
        {
          "name": "Quantity",
          "width": 12,
        },
        {
          "name": "Unit Price",
          "width": 15,
        },
        {
          "name": "Amount",
          "width": 15,
        }
      ],
      "rows": [
        [
          {
            "value": "CloudMetrics Inc. — Billing Statement",
            "styles": {
              "is_bold": true,
              "font_size_in_pt": 14,
            },
            "from_col": 0,
            "to_col": 4,
          }
        ],
        [
          {
            "value": "Customer: Pinnacle Retail Group | Account #ACT-78412",
            "from_col": 0,
            "to_col": 4,
          }
        ],
        [
          {
            "value": "Billing Period: March 1–31, 2026 | Due: April 15, 2026",
            "from_col": 0,
            "to_col": 4,
          }
        ],
        [
          {
            "value": "",
          }
        ],
        [
          {
            "value": "2026-03-01",
            "format": "date",
          },
          {
            "value": "Business Plan — Monthly Subscription",
          },
          {
            "value": 1,
            "format": "number",
          },
          {
            "value": 499,
            "format": "currency",
          },
          {
            "value": 499,
            "format": "currency",
          }
        ],
        [
          {
            "value": "2026-03-01",
            "format": "date",
          },
          {
            "value": "Additional Seats (15 seats)",
          },
          {
            "value": 15,
            "format": "number",
          },
          {
            "value": 12,
            "format": "currency",
          },
          {
            "value": 180,
            "format": "currency",
          }
        ],
        [
          {
            "value": "2026-03-15",
            "format": "date",
          },
          {
            "value": "API Overage — 52,000 extra requests",
          },
          {
            "value": 52,
            "format": "number",
          },
          {
            "value": 0.50,
            "format": "currency",
          },
          {
            "value": 26,
            "format": "currency",
          }
        ],
        [
          {
            "value": "2026-03-15",
            "format": "date",
          },
          {
            "value": "Storage Overage — 120 GB above plan",
          },
          {
            "value": 120,
            "format": "number",
          },
          {
            "value": 0.15,
            "format": "currency",
          },
          {
            "value": 18,
            "format": "currency",
          }
        ],
        [
          {
            "value": "2026-03-01",
            "format": "date",
          },
          {
            "value": "Annual Loyalty Credit",
          },
          {
            "value": 1,
            "format": "number",
          },
          {
            "value": -50,
            "format": "currency",
          },
          {
            "value": -50,
            "format": "currency",
          }
        ],
        [
          {
            "value": "",
          }
        ],
        [
          {
            "value": "",
          },
          {
            "value": "",
          },
          {
            "value": "",
          },
          {
            "value": "Subtotal",
            "styles": {
              "is_bold": true,
            },
          },
          {
            "value": null,
          }
        ],
        [
          {
            "value": "",
          },
          {
            "value": "",
          },
          {
            "value": "",
          },
          {
            "value": "Tax (9.5%)",
            "styles": {
              "is_bold": true,
            },
          },
          {
            "value": null,
          }
        ],
        [
          {
            "value": "",
          },
          {
            "value": "",
          },
          {
            "value": "",
          },
          {
            "value": "Total Due",
            "styles": {
              "is_bold": true,
              "font_size_in_pt": 13,
            },
          },
          {
            "value": null,
            "styles": {
              "is_bold": true,
              "font_size_in_pt": 13,
            },
          }
        ]
      ],
      "formulas": [
        {
          "row": 10,
          "col": 4,
          "expression": "=SUM(E5:E9)",
        },
        {
          "row": 11,
          "col": 4,
          "expression": "=E11*0.095",
        },
        {
          "row": 12,
          "col": 4,
          "expression": "=E11+E12",
        }
      ],
      "merged_cells": [
        {
          "start_row": 0,
          "start_col": 0,
          "end_row": 0,
          "end_col": 4,
        },
        {
          "start_row": 1,
          "start_col": 0,
          "end_row": 1,
          "end_col": 4,
        },
        {
          "start_row": 2,
          "start_col": 0,
          "end_row": 2,
          "end_col": 4,
        }
      ]
    }
    ]
  }'
Response
{
  "success": true,
  "data": {
    "buffer": "UEsDBBQAAAAIAA...",
    "mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  }
}
Request
import { IterationLayer } from "iterationlayer";
const client = new IterationLayer({
  apiKey: "YOUR_API_KEY",
});

const result = await client.generateSheet({
  format: "xlsx",
  styles: {
    header: {
      font_family: "Helvetica",
      font_size_in_pt: 11,
      is_bold: true,
      background_color: "#4A148C",
      font_color: "#FFFFFF",
    },
    body: {
      font_family: "Helvetica",
      font_size_in_pt: 11,
      font_color: "#333333",
    },
  },
  sheets: [
    {
    name: "Statement — March 2026",
    columns: [
      {
        name: "Date",
        width: 14,
      },
      {
        name: "Description",
        width: 40,
      },
      {
        name: "Quantity",
        width: 12,
      },
      {
        name: "Unit Price",
        width: 15,
      },
      {
        name: "Amount",
        width: 15,
      },
    ],
    rows: [
      [
        {
          value: "CloudMetrics Inc. — Billing Statement",
          styles: {
            is_bold: true,
            font_size_in_pt: 14,
          },
          from_col: 0,
          to_col: 4,
        },
      ],
      [
        {
          value: "Customer: Pinnacle Retail Group | Account #ACT-78412",
          from_col: 0,
          to_col: 4,
        },
      ],
      [
        {
          value: "Billing Period: March 1–31, 2026 | Due: April 15, 2026",
          from_col: 0,
          to_col: 4,
        },
      ],
      [
        {
          value: "",
        },
      ],
      [
        {
          value: "2026-03-01",
          format: "date",
        },
        {
          value: "Business Plan — Monthly Subscription",
        },
        {
          value: 1,
          format: "number",
        },
        {
          value: 499,
          format: "currency",
        },
        {
          value: 499,
          format: "currency",
        },
      ],
      [
        {
          value: "2026-03-01",
          format: "date",
        },
        {
          value: "Additional Seats (15 seats)",
        },
        {
          value: 15,
          format: "number",
        },
        {
          value: 12,
          format: "currency",
        },
        {
          value: 180,
          format: "currency",
        },
      ],
      [
        {
          value: "2026-03-15",
          format: "date",
        },
        {
          value: "API Overage — 52,000 extra requests",
        },
        {
          value: 52,
          format: "number",
        },
        {
          value: 0.50,
          format: "currency",
        },
        {
          value: 26,
          format: "currency",
        },
      ],
      [
        {
          value: "2026-03-15",
          format: "date",
        },
        {
          value: "Storage Overage — 120 GB above plan",
        },
        {
          value: 120,
          format: "number",
        },
        {
          value: 0.15,
          format: "currency",
        },
        {
          value: 18,
          format: "currency",
        },
      ],
      [
        {
          value: "2026-03-01",
          format: "date",
        },
        {
          value: "Annual Loyalty Credit",
        },
        {
          value: 1,
          format: "number",
        },
        {
          value: -50,
          format: "currency",
        },
        {
          value: -50,
          format: "currency",
        },
      ],
      [
        {
          value: "",
        },
      ],
      [
        {
          value: "",
        },
        {
          value: "",
        },
        {
          value: "",
        },
        {
          value: "Subtotal",
          styles: {
            is_bold: true,
          },
        },
        {
          value: null,
        },
      ],
      [
        {
          value: "",
        },
        {
          value: "",
        },
        {
          value: "",
        },
        {
          value: "Tax (9.5%)",
          styles: {
            is_bold: true,
          },
        },
        {
          value: null,
        },
      ],
      [
        {
          value: "",
        },
        {
          value: "",
        },
        {
          value: "",
        },
        {
          value: "Total Due",
          styles: {
            is_bold: true,
            font_size_in_pt: 13,
          },
        },
        {
          value: null,
          styles: {
            is_bold: true,
            font_size_in_pt: 13,
          },
        },
      ],
    ],
    formulas: [
      {
        row: 10,
        col: 4,
        expression: "=SUM(E5:E9)",
      },
      {
        row: 11,
        col: 4,
        expression: "=E11*0.095",
      },
      {
        row: 12,
        col: 4,
        expression: "=E11+E12",
      },
    ],
    merged_cells: [
      {
        start_row: 0,
        start_col: 0,
        end_row: 0,
        end_col: 4,
      },
      {
        start_row: 1,
        start_col: 0,
        end_row: 1,
        end_col: 4,
      },
      {
        start_row: 2,
        start_col: 0,
        end_row: 2,
        end_col: 4,
      },
    ],
  }
  ],
});
Response
{
  "success": true,
  "data": {
    "buffer": "UEsDBBQAAAAIAA...",
    "mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  }
}
Request
from iterationlayer import IterationLayer
client = IterationLayer(api_key="YOUR_API_KEY")

result = client.generate_sheet(
    format="xlsx",
    styles={
        "header": {
            "font_family": "Helvetica",
            "font_size_in_pt": 11,
            "is_bold": True,
            "background_color": "#4A148C",
            "font_color": "#FFFFFF",
        },
        "body": {
            "font_family": "Helvetica",
            "font_size_in_pt": 11,
            "font_color": "#333333",
        },
    },
    sheets=[
        {
        "name": "Statement — March 2026",
        "columns": [
            {
                "name": "Date",
                "width": 14,
            },
            {
                "name": "Description",
                "width": 40,
            },
            {
                "name": "Quantity",
                "width": 12,
            },
            {
                "name": "Unit Price",
                "width": 15,
            },
            {
                "name": "Amount",
                "width": 15,
            },
        ],
        "rows": [
            [
                {
                    "value": "CloudMetrics Inc. — Billing Statement",
                    "styles": {
                        "is_bold": True,
                        "font_size_in_pt": 14,
                    },
                    "from_col": 0,
                    "to_col": 4,
                },
            ],
            [
                {
                    "value": "Customer: Pinnacle Retail Group | Account #ACT-78412",
                    "from_col": 0,
                    "to_col": 4,
                },
            ],
            [
                {
                    "value": "Billing Period: March 1–31, 2026 | Due: April 15, 2026",
                    "from_col": 0,
                    "to_col": 4,
                },
            ],
            [
                {
                    "value": "",
                },
            ],
            [
                {
                    "value": "2026-03-01",
                    "format": "date",
                },
                {
                    "value": "Business Plan — Monthly Subscription",
                },
                {
                    "value": 1,
                    "format": "number",
                },
                {
                    "value": 499,
                    "format": "currency",
                },
                {
                    "value": 499,
                    "format": "currency",
                },
            ],
            [
                {
                    "value": "2026-03-01",
                    "format": "date",
                },
                {
                    "value": "Additional Seats (15 seats)",
                },
                {
                    "value": 15,
                    "format": "number",
                },
                {
                    "value": 12,
                    "format": "currency",
                },
                {
                    "value": 180,
                    "format": "currency",
                },
            ],
            [
                {
                    "value": "2026-03-15",
                    "format": "date",
                },
                {
                    "value": "API Overage — 52,000 extra requests",
                },
                {
                    "value": 52,
                    "format": "number",
                },
                {
                    "value": 0.50,
                    "format": "currency",
                },
                {
                    "value": 26,
                    "format": "currency",
                },
            ],
            [
                {
                    "value": "2026-03-15",
                    "format": "date",
                },
                {
                    "value": "Storage Overage — 120 GB above plan",
                },
                {
                    "value": 120,
                    "format": "number",
                },
                {
                    "value": 0.15,
                    "format": "currency",
                },
                {
                    "value": 18,
                    "format": "currency",
                },
            ],
            [
                {
                    "value": "2026-03-01",
                    "format": "date",
                },
                {
                    "value": "Annual Loyalty Credit",
                },
                {
                    "value": 1,
                    "format": "number",
                },
                {
                    "value": -50,
                    "format": "currency",
                },
                {
                    "value": -50,
                    "format": "currency",
                },
            ],
            [
                {
                    "value": "",
                },
            ],
            [
                {
                    "value": "",
                },
                {
                    "value": "",
                },
                {
                    "value": "",
                },
                {
                    "value": "Subtotal",
                    "styles": {
                        "is_bold": True,
                    },
                },
                {
                    "value": None,
                },
            ],
            [
                {
                    "value": "",
                },
                {
                    "value": "",
                },
                {
                    "value": "",
                },
                {
                    "value": "Tax (9.5%)",
                    "styles": {
                        "is_bold": True,
                    },
                },
                {
                    "value": None,
                },
            ],
            [
                {
                    "value": "",
                },
                {
                    "value": "",
                },
                {
                    "value": "",
                },
                {
                    "value": "Total Due",
                    "styles": {
                        "is_bold": True,
                        "font_size_in_pt": 13,
                    },
                },
                {
                    "value": None,
                    "styles": {
                        "is_bold": True,
                        "font_size_in_pt": 13,
                    },
                },
            ],
        ],
        "formulas": [
            {
                "row": 10,
                "col": 4,
                "expression": "=SUM(E5:E9)",
            },
            {
                "row": 11,
                "col": 4,
                "expression": "=E11*0.095",
            },
            {
                "row": 12,
                "col": 4,
                "expression": "=E11+E12",
            },
        ],
        "merged_cells": [
            {
                "start_row": 0,
                "start_col": 0,
                "end_row": 0,
                "end_col": 4,
            },
            {
                "start_row": 1,
                "start_col": 0,
                "end_row": 1,
                "end_col": 4,
            },
            {
                "start_row": 2,
                "start_col": 0,
                "end_row": 2,
                "end_col": 4,
            },
        ],
    }
    ],
)
Response
{
  "success": true,
  "data": {
    "buffer": "UEsDBBQAAAAIAA...",
    "mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  }
}
Request
package main

import il "github.com/iterationlayer/sdk-go"

func main() {
    client := il.NewClient("YOUR_API_KEY")

    result, err := client.GenerateSheet(il.GenerateSheetRequest{
        Format: "xlsx",
        Styles: &il.SheetStyles{
            Header: &il.CellStyle{
                FontFamily:      "Helvetica",
                FontSizeInPt:    11,
                IsBold:          true,
                BackgroundColor: "#4A148C",
                FontColor:       "#FFFFFF",
            },
            Body: &il.CellStyle{
                FontFamily:   "Helvetica",
                FontSizeInPt: 11,
                FontColor:    "#333333",
            },
        },
        Sheets: []il.Sheet{
            {
            Name: "Statement — March 2026",
            Columns: []il.SheetColumn{
                {
                    Name:  "Date",
                    Width: 14,
                },
                {
                    Name:  "Description",
                    Width: 40,
                },
                {
                    Name:  "Quantity",
                    Width: 12,
                },
                {
                    Name:  "Unit Price",
                    Width: 15,
                },
                {
                    Name:  "Amount",
                    Width: 15,
                },
            },
            Rows: []il.SheetRow{
                {
                    {
                        Value: "CloudMetrics Inc. — Billing Statement",
                        Styles: &il.CellStyle{
                            IsBold:       true,
                            FontSizeInPt: 14,
                        },
                        FromCol: intPtr(0),
                        ToCol:   intPtr(4),
                    },
                },
                {
                    {
                        Value:   "Customer: Pinnacle Retail Group | Account #ACT-78412",
                        FromCol: intPtr(0),
                        ToCol:   intPtr(4),
                    },
                },
                {
                    {
                        Value:   "Billing Period: March 1–31, 2026 | Due: April 15, 2026",
                        FromCol: intPtr(0),
                        ToCol:   intPtr(4),
                    },
                },
                {
                    {
                        Value: "",
                    },
                },
                {
                    {
                        Value:  "2026-03-01",
                        Format: "date",
                    },
                    {
                        Value: "Business Plan — Monthly Subscription",
                    },
                    {
                        Value:  1,
                        Format: "number",
                    },
                    {
                        Value:  499,
                        Format: "currency",
                    },
                    {
                        Value:  499,
                        Format: "currency",
                    },
                },
                {
                    {
                        Value:  "2026-03-01",
                        Format: "date",
                    },
                    {
                        Value: "Additional Seats (15 seats)",
                    },
                    {
                        Value:  15,
                        Format: "number",
                    },
                    {
                        Value:  12,
                        Format: "currency",
                    },
                    {
                        Value:  180,
                        Format: "currency",
                    },
                },
                {
                    {
                        Value:  "2026-03-15",
                        Format: "date",
                    },
                    {
                        Value: "API Overage — 52,000 extra requests",
                    },
                    {
                        Value:  52,
                        Format: "number",
                    },
                    {
                        Value:  0.50,
                        Format: "currency",
                    },
                    {
                        Value:  26,
                        Format: "currency",
                    },
                },
                {
                    {
                        Value:  "2026-03-15",
                        Format: "date",
                    },
                    {
                        Value: "Storage Overage — 120 GB above plan",
                    },
                    {
                        Value:  120,
                        Format: "number",
                    },
                    {
                        Value:  0.15,
                        Format: "currency",
                    },
                    {
                        Value:  18,
                        Format: "currency",
                    },
                },
                {
                    {
                        Value:  "2026-03-01",
                        Format: "date",
                    },
                    {
                        Value: "Annual Loyalty Credit",
                    },
                    {
                        Value:  1,
                        Format: "number",
                    },
                    {
                        Value:  -50,
                        Format: "currency",
                    },
                    {
                        Value:  -50,
                        Format: "currency",
                    },
                },
                {
                    {
                        Value: "",
                    },
                },
                {
                    {
                        Value: "",
                    },
                    {
                        Value: "",
                    },
                    {
                        Value: "",
                    },
                    {
                        Value: "Subtotal",
                        Styles: &il.CellStyle{
                            IsBold: true,
                        },
                    },
                    {
                        Value: nil,
                    },
                },
                {
                    {
                        Value: "",
                    },
                    {
                        Value: "",
                    },
                    {
                        Value: "",
                    },
                    {
                        Value: "Tax (9.5%)",
                        Styles: &il.CellStyle{
                            IsBold: true,
                        },
                    },
                    {
                        Value: nil,
                    },
                },
                {
                    {
                        Value: "",
                    },
                    {
                        Value: "",
                    },
                    {
                        Value: "",
                    },
                    {
                        Value: "Total Due",
                        Styles: &il.CellStyle{
                            IsBold:       true,
                            FontSizeInPt: 13,
                        },
                    },
                    {
                        Value: nil,
                        Styles: &il.CellStyle{
                            IsBold:       true,
                            FontSizeInPt: 13,
                        },
                    },
                },
            },
            Formulas: []il.Formula{
                {
                    Row:        10,
                    Col:        4,
                    Expression: "=SUM(E5:E9)",
                },
                {
                    Row:        11,
                    Col:        4,
                    Expression: "=E11*0.095",
                },
                {
                    Row:        12,
                    Col:        4,
                    Expression: "=E11+E12",
                },
            },
            MergedCells: []il.MergedCell{
                {
                    StartRow: 0,
                    StartCol: 0,
                    EndRow:   0,
                    EndCol:   4,
                },
                {
                    StartRow: 1,
                    StartCol: 0,
                    EndRow:   1,
                    EndCol:   4,
                },
                {
                    StartRow: 2,
                    StartCol: 0,
                    EndRow:   2,
                    EndCol:   4,
                },
            },
        },
        },
    })
    if err != nil {
        panic(err)
    }
    _ = result
}
Response
{
  "success": true,
  "data": {
    "buffer": "UEsDBBQAAAAIAA...",
    "mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  }
}

Related Recipes

Start building in minutes

Free trial credits included. No credit card required.