Scheduler - Import and Export
Work with event, resource, category, and recurrence data for import and export flows.
#Usage
import { Scheduler } from '@primeui/vue-scheduler';<Scheduler.Root :events="events" :resources="resources" :categories="categories" :date="date" @dates-change="onDatesChange" @event-change="onEventChange">
<!-- Scheduler parts -->
</Scheduler.Root>Import and export are controlled-data workflows. Keep events, resources, and categories in page or app state, then use the Scheduler helpers to serialize outbound data or normalize imported packets before replacing that state.
#Data Contract
Scheduler imports and exports the same public event shape used by the live component. Event placement depends on id, title, start, and either end or duration. Resource and category fields stay on the event so imported data can move directly into resource views, legends, drag rules, and overlays.
import type { SchedulerEvent } from '@primeui/vue-scheduler';
const importedEvents: SchedulerEvent[] = [
{
id: 'release-freeze',
title: 'Release Freeze',
start: new Date(2026, 5, 10, 9, 0),
end: new Date(2026, 5, 10, 10, 30),
resourceId: 'launch-desk',
categoryId: 'launch',
metadata: {
uid: '[email protected]',
owner: 'Release desk'
}
}
];Use metadata.uid when an external system has a stable event id. The import merge helpers use that UID before falling back to id, which makes repeated imports safer.
#Export
Choose the export helper that matches the destination. JSON is the richest app-to-app format because it can include events, resources, categories, schemaVersion, and app metadata. CSV is easier for spreadsheet review. iCal is the calendar-client format and preserves fields such as UID, location, description, and recurrence when the source data has them.
import { downloadExport, exportToCsv, exportToIcal, exportToJson } from '@primeui/vue-scheduler';
const jsonExport = exportToJson(
events,
{
includeResources: true,
includeCategories: true,
schemaVersion: '2.0.0',
filename: 'schedule.json'
},
resources,
categories
);
const csvExport = exportToCsv(events, {
columns: ['id', 'title', 'start', 'end', 'resourceId', 'categoryId']
});
const icalExport = exportToIcal(events, {
calendarName: 'Release Calendar',
includeRecurring: true
});Export helpers return an ExportResult with data, filename, mimeType, and size. In a browser, pass that result to downloadExport, or send the payload to your own storage/API layer.
#Import
Use the matching import helper for known content, or importScheduler(file) when a user selects a file and the extension should decide the parser. Each parser returns an ImportResult with normalized events plus errors, warnings, and any JSON-provided resources or categories.
import { importFromCsv, importFromIcal, importFromJson, previewImportMerge } from '@primeui/vue-scheduler';
const result = await importFromJson(jsonText, {
validateSchema: true,
schemaVersion: '2.0.0'
});
const preview = previewImportMerge(events, result.events, {
strategy: 'replace-in-range',
existingResources: resources,
existingCategories: categories,
createMissingResources: true,
createMissingCategories: true
});The import result is intentionally separate from the live Scheduler state. Review errors and warnings, build a merge preview, then apply the preview or call applyImportMerge when the page is ready to update events.
#Formats
JSON accepts either an event array or an object with events, resources, categories, schemaVersion, and optional metadata. Date fields are converted back to Date instances, and migration hooks can move older payloads to a newer schema version.
CSV maps common headers such as title, start, end, resourceId, categoryId, allDay, color, and metadata.*. Use columnMapping when a spreadsheet uses names such as owner, room, or scheduled_start.
iCal reads UID, SUMMARY, DTSTART, DTEND, DURATION, DESCRIPTION, LOCATION, RRULE, EXDATE, and related calendar fields. UID is stored in metadata.uid, which is useful for upsert-by-uid imports.
#Merge and Validation
previewImportMerge lets the page show what will happen before state changes. Use append for additive imports, upsert-by-uid for repeated packets from the same source, and replace-in-range when an imported packet owns a date window.
import { applyImportMerge, buildImportValidationReport } from '@primeui/vue-scheduler';
const report = buildImportValidationReport(result);
if (!report.summary.hasBlockingIssues) {
events = applyImportMerge(events, result.events, {
strategy: 'upsert-by-uid',
existingResources: resources,
existingCategories: categories,
conflictPolicy: {
mode: 'warn',
checkOverlap: true
}
});
}Conflict checks can warn or reject overlapping events, resource constraint violations, and business-hours violations. Resource and category mapping options keep imported ids connected to the application model instead of leaving unknown ids in the schedule.
#Import Review
Imported events can be reviewed in resource views before the page commits a merge. The normalized event fields still drive event placement, resource matching, and interaction behavior.
#API
Relevant helpers include exportToJson, exportToCsv, exportToIcal, exportScheduler, downloadExport, importFromJson, importFromCsv, importFromIcal, importScheduler, validateImportResult, buildImportValidationReport, previewImportMerge, and applyImportMerge. Relevant data fields include events, resources, categories, event start, end, resourceId, resourceIds, categoryId, categoryIds, metadata.uid, export dateRange, includeRecurring, expandRecurring, import schemaVersion, and merge strategy.