Export
Pantanal Grid supports exporting data to Excel (CSV) and PDF formats with customizable options.
Basic Excel Export
Add 'excel' to the toolbar to enable Excel export. By default, only the current page is exported. Click the Excel button in the toolbar to export the data.
Export All Pages
Set excelAllPages to true to export all data pages instead of just the current page. This is useful when you have paginated data and want to export everything.
Custom File Name
Specify a custom file name using the excelFileName prop. The file will be exported as CSV format (which Excel opens correctly).
Excel Export
Basic Usage
Add 'excel' to the toolbar to enable Excel export:
<PantanalGrid
:rows="rows"
:columns="columns"
key-field="id"
:toolbar="['excel']"
/>Export All Pages
Set excelAllPages to true to export all data pages:
<PantanalGrid
:rows="rows"
:columns="columns"
key-field="id"
:toolbar="['excel']"
:excel-all-pages="true"
:pageable="true"
/>Custom File Name
Specify a custom file name:
<PantanalGrid
:rows="rows"
:columns="columns"
key-field="id"
:toolbar="['excel']"
:excel-file-name="'my-export.csv'"
/>PDF Export
Basic PDF Export
Add 'pdf' to the toolbar to enable PDF export. By default, the current view is exported. Note: PDF export requires jspdf and html2canvas libraries. Click the PDF button in the toolbar to export the data.
Landscape Orientation
Configure paper size and orientation using pdfPaperSize and pdfLandscape props. Use landscape orientation for wider tables.
Custom Margins
Specify custom margins using the pdfMargin prop. Margins can be specified as strings (e.g., "2cm") or numbers (in mm).
Custom File Name
Specify a custom file name using the pdfFileName prop.
Basic Usage
Add 'pdf' to the toolbar. Note: PDF export requires jspdf and html2canvas libraries:
<PantanalGrid
:rows="rows"
:columns="columns"
key-field="id"
:toolbar="['pdf']"
/>Paper Size and Orientation
<PantanalGrid
:rows="rows"
:columns="columns"
key-field="id"
:toolbar="['pdf']"
:pdf-paper-size="'A4'"
:pdf-landscape="true"
/>Custom Margins
<PantanalGrid
:rows="rows"
:columns="columns"
key-field="id"
:toolbar="['pdf']"
:pdf-margin="{ top: '2cm', left: '1cm', right: '1cm', bottom: '1cm' }"
/>Custom File Name
<PantanalGrid
:rows="rows"
:columns="columns"
key-field="id"
:toolbar="['pdf']"
:pdf-file-name="'my-export.pdf'"
/>Programmatic Export
You can also trigger exports programmatically using the grid's exposed methods:
<script setup lang="ts">
import { ref } from 'vue'
import { PantanalGrid } from '@pantanal/grid'
const gridRef = ref<InstanceType<typeof PantanalGrid> | null>(null)
function exportToExcel() {
gridRef.value?.exportToExcel()
}
function exportToPdf() {
gridRef.value?.exportToPdf()
}
</script>
<template>
<div>
<button @click="exportToExcel">Export to Excel</button>
<button @click="exportToPdf">Export to PDF</button>
<PantanalGrid
ref="gridRef"
:rows="rows"
:columns="columns"
key-field="id"
/>
</div>
</template>See Also
- PantanalGrid API - Complete API reference
- Export Guide - Detailed export documentation