The onBeforeCellExport event handler fires during image and Excel export. It lets you provide alternative text and export styling for Gantt Chart grid cells because the exported file doesn't support HTML in grid cells.
Available since version 2023.1.5529.
Declaration
DayPilot.Gantt.onBeforeCellExport(args)Parameters
args.areas(array) - active areas included in the exported cell; areas defined using DayPilot.Gantt.onBeforeCellRender are copied.args.cell- exported grid cell object (read-only).args.fontColor(string) - font color.args.fontFamily(string) - font family.args.fontSize(string) - font size.args.fontStyle(string) - font style.args.text(string) - exported text.args.horizontalAlignment("left"|"center"|"right") - horizontal text alignment.args.backColor(string) - background color.
Notes
Use this event when the rendered cell contains HTML that needs a plain-text replacement in the exported image. You can reformat the output by updating args.text before the image is generated.
Active Areas in Image Export
For PNG, JPEG and SVG export, args.areas contains copies of the active-area descriptors prepared for this item. Replace it or assign [] to change only the exported areas. The export does not call an area’s onAfterRender DOM callback. Custom HTML remains outside the supported image-export representation.
Examples
JavaScript
const gantt = new DayPilot.Gantt("dp", {
onBeforeCellExport: (args) => {
args.text = String(args.text || "").replace(/<br\s*\/?>/g, "\n");
},
// ...
});
gantt.init();Angular
<daypilot-gantt [config]="config"></daypilot-gantt>config: DayPilot.GanttConfig = {
onBeforeCellExport: args => {
args.text = String(args.text || "").replace(/<br\s*\/?>/g, "\n");
},
// ...
};React
<DayPilotGantt
onBeforeCellExport={onBeforeCellExport}
/>const onBeforeCellExport = (args) => {
args.text = String(args.text || "").replace(/<br\s*\/?>/g, "\n");
};Vue
<DayPilotGantt
:onBeforeCellExport="onBeforeCellExport"
/>const onBeforeCellExport = (args) => {
args.text = String(args.text || "").replace(/<br\s*\/?>/g, "\n");
};See Also
Client-Side Image Export [doc.daypilot.org]
DayPilot.Gantt.onBeforeCellRender
Availability
Availability of this API item in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript |
DayPilot