---
url: https://vue-json-excel3.netlify.app/cell-format-xlsx-examples.md
description: >-
  Apply Excel number formats (currency, percentage, decimals) and column widths
  to .xlsx exports.
---

# Cell Formats & Widths

::: warning
`formats` and `widths` only work with `type="xlsx"`.
:::

`formats` maps a **column letter** to an Excel number format string. `widths` maps a column letter to a width in characters (supported from **v1.0.26**).

```vue
<script setup>
import JsonExcel from 'vue-json-excel3'

const jsonData = [
  { name: 'Alice', salary: 50000, percentage: 0.75, number: 123.456 },
  { name: 'Bob', salary: 60000, percentage: 0.85, number: 789.123 },
]

// Keyed by column letter
const formats = {
  B: '"$"#,##0.00_);\\("$"#,##0.00\\)', // currency
  C: '0.00%', // percentage
  D: '0.00', // number
}

// Column widths in characters (v1.0.26+)
const widths = { A: 14, B: 14, C: 10, D: 10 }
</script>

<template>
  <JsonExcel
    class="btn"
    :data="jsonData"
    :formats="formats"
    :widths="widths"
    type="xlsx"
    worksheet="My Worksheet"
    name="formatted.xlsx"
  >
    Download formatted .xlsx
  </JsonExcel>
</template>
```

## Common formats

| Format | Example output |
| :--- | :--- |
| `'0.00'` | `123.46` |
| `'#,##0'` | `50,000` |
| `'0.00%'` | `75.00%` |
| `'"$"#,##0.00_);\\("$"#,##0.00\\)'` | `$50,000.00` |
| `'yyyy-mm-dd'` | `2024-03-15` |
