Use the ComponentOne ASP.NET Export Service, to export EventsCalendar to Excel, CSV and PDF, without creating a complex export application. This service resides on the application server.
The advantages of using ComponentOne ASP.NET Export Service are:
Export Service is a web-application that is deployed on Internet Information Services (IIS). Run the C1ASPNETExportService installer, placed in C:\Program Files\ComponentOne\ASP.NET Web Forms Edition folder. It installs the following files in IIS.
You can also locate these files at the following location:
C:\ProgramData\ComponentOne\C1ASPNET\C1ASPNETExportService
Following are the system requirements of the service host:
Following are the settings, to download the eventscalendar in various formats:
Export to Excel
Export to CSV:
Export to PDF
The exportEventsCalendar
method will be called to export the EventsCalendar content to Excel, CSV or PDF. These steps assume that you have added a button to the form, on whose click event you would call the export function. Add the following code within the <head></head>
tags, to export the EventsCalendar to Excel.
<script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script> <asp:PlaceHolder runat="server"> <script type="text/javascript"> $(function () { $("#Button1").click(exportExcel); }); // Export function function exportExcel() { var fileName = "ExportedEventsCalendar"; var type = "Xls"; var excelSetting = { autoRowHeight: true, author: "ComponentOne" }; var url = "http://demos.componentone.com/ASPNET/ExportService" + "/exportapi/eventscalendar"; $("#<%=C1EventsCalendar1.ClientID%>").c1eventscalendar("exportEventsCalendar", fileName, type, excelSetting, url); } </script> </asp:PlaceHolder>
Add the following code within the <head></head>
tags, to export the EventsCalendar to a CSV file:
<script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script> <asp:PlaceHolder ID="PlaceHolder1" runat="server"> <script type="text/javascript"> $(function () { $("#Button1").click(exportCsv); }); // Export function function exportCsv() { var fileName = "ExportedEventsCalendar"; var url = "http://demos.componentone.com/ASPNET/ExportService" + "/exportapi/eventscalendar"; $("#<%=C1EventsCalendar1.ClientID%>").c1eventscalendar("exportEventsCalendar", fileName, "csv", url); } </script> </asp:PlaceHolder>
Add the following code within the <head></head>
tags, to export the EventsCalendar to a PDF:
<script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script> <asp:PlaceHolder ID="PlaceHolder1" runat="server"> <script type="text/javascript"> $(function () { $("#Button1").click(exportPdf); }); // pdf settings function getPdfSetting() { return { repeatHeader: true, landscape: true, autoFitWidth: true, pageSize: { width: 300, height: 400 }, paperKind: 'A4', margins: { top: 50, right: 50, bottom: 50, left: 50 }, imageQuality:'Low', compression: 'BestCompression', fontType: 'TrueType', author: 'ComponentOne', creator: 'ComponentOne', subject: 'EventsCalendar Export', title: 'EventsCalendar Export', producer: 'ComponentOne', keywords: 'EventsCalendar, EventsCalendar, Export, PDF', encryption: 'NotPermit', ownerPassword: '0000', userPassword: '00000', allowCopyContent: true, allowEditAnnotations: true, allowEditContent: true, allowPrint: true, } } // Export function function exportPdf() { var fileName = 'ExportEventsCalendar'; var pdfSetting = getPdfSetting(); var url = "http://demos.componentone.com/ASPNET/ExportService" + "/exportapi/eventscalendar"; $("#<%=C1EventsCalendar1.ClientID%>").c1eventscalendar("exportEventsCalendar", fileName, "pdf", pdfSetting, url); } </script> </asp:PlaceHolder>
The following image displays the PDF generated:
In case the file is not downloaded on Internet Explorer, turn off Internet Explorer protected mode to export file or run Internet Explorer as administrator. To turn off the protected mode: