DayPilot Knowledge Base

AJAX Calendar/Scheduling Controls
DayPilot Pro (AJAX Calendar Control)
» DayPilot ASP.NET Calendar
DayPilot Pro (AJAX Monthly Calendar Control)
» DayPilot ASP.NET Monthly Calendar
DayPilot Pro (AJAX Scheduler Control)
» DayPilot ASP.NET Scheduler
DayPilot » Knowledge Base » How to save the exported PNG image to a file (without a web page)

How to save the exported PNG image to a file (without a web page)

Last revision: Feb 10, 2011

scheduler png export

The Scheduler image export can be used outside of ASP.NET web pages.

You need to create the control and set all the necessary properties in the code.


This is a minimal example that saves the image to a file (default colors and fonts):

        DayPilotScheduler s = new DayPilotScheduler();
        s.DataStartField = "start";
        s.DataEndField = "end";
        s.DataResourceField = "resource";
        s.DataTextField = "name";
        s.DataValueField = "id";
        s.DataSource = getBackgroundData();
        s.Resources.Add("Resource A", "A");
        s.StartDate = DateTime.Today;
        s.Days = 1;
        MemoryStream ms = s.Export(ImageFormat.Png);

        using (FileStream fs = new FileStream("c:/var/log/aspnet/output.png", FileMode.CreateNew))


Testing data generator:

    private DataTable getBackgroundData()
        DataTable dt;
        dt = new DataTable();
        dt.Columns.Add("start", typeof(DateTime));
        dt.Columns.Add("end", typeof(DateTime));
        dt.Columns.Add("name", typeof(string));
        dt.Columns.Add("id", typeof(string));
        dt.Columns.Add("resource", typeof(string));

        DataRow dr;

        dr = dt.NewRow();
        dr["id"] = 1;
        dr["start"] = Convert.ToDateTime("15:00");
        dr["end"] = Convert.ToDateTime("16:00").AddDays(2);
        dr["name"] = "First";
        dr["resource"] = "A";

        return dt;


How to set the time cell colors using database data in the Scheduler
How to load Scheduler resource tree from a database (SQL Server)
How to implement Copy & Paste in the Calendar
How to show one month per cell in Scheduler (CellDuration = Month)