导出为 Excel 和 iCal

从 4.2 版本开始,dhtmlxScheduler 支持将所有调度器数据导出为 Excel 和 iCal 格式。

请求大小限制

有一个共享的 API 端点 https://export.dhtmlx.com/scheduler,用于多种导出方法(如 exportToPDFexportToPNG 等)。最大请求大小为 10 MB

导出为 Excel

要将调度器数据导出为 Excel 文件,请按照以下步骤操作:

  1. 在页面中添加 "https://export.dhtmlx.com/scheduler/api.js" 脚本以启用在线导出服务:
    <script src="codebase/dhtmlxscheduler.js"></script>
    <script src="https://export.dhtmlx.com/scheduler/api.js"></script>  <link rel="stylesheet" href="codebase/dhtmlxscheduler.css" type="text/css">
  2. 使用 exportToExcel 方法导出调度器数据:
    <input value="Export to Excel" type="button" onclick="scheduler.exportToExcel()"> 
    <script>
        scheduler.init("scheduler_here",new Date(2019,5,30),"month");
        scheduler.load("data/events");
    </script>

导出方法的参数

exportToExcel() 方法可以接受一个可选对象,包含以下属性:


调用导出方法并传入可选属性

scheduler.exportToExcel({
    name:"My document.xls", 
    columns:[
        { id:"text",  header:"Title", width:150 },
        { id:"start_date",  header:"Start date", width:250 }
    ],
    server:"https://myapp.com/myexport/scheduler",
    start: new Date(1999, 01, 01),
    end:  new Date(2022, 01, 01)
});

设置日期格式

如需控制导出的 Excel 文件中日期的显示方式,可以这样设置 xml_format 模板:

scheduler.templates.xml_format = scheduler.date.date_to_str("%Y-%m-%d %H:%i");

Related sample:  Setting date format

关于日期格式的更多细节,请参阅此处的说明。

导出为 iCal

要将调度器数据导出为 iCal 字符串,请按照以下步骤操作:

  • 引入 "https://export.dhtmlx.com/scheduler/api.js" 脚本以启用在线导出服务:
<script src="codebase/dhtmlxscheduler.js"></script>
<script src="https://export.dhtmlx.com/scheduler/api.js"></script>  <link rel="stylesheet" href="codebase/dhtmlxscheduler.css" type="text/css">
  • 使用 exportToICal 方法导出调度器数据:
<input value="Export to iCal" type="button" onclick="scheduler.exportToICal()"> 
<script>
    scheduler.init("scheduler_here",new Date(2019,5,30),"month");
    scheduler.load("data/events");
</script>

导出方法的参数

exportToICal() 方法可以接受一个可选对象,包含如下属性:


调用导出方法并传入可选属性

scheduler.exportToICal({
    server:"https://myapp.com/myexport/scheduler"
});
返回顶部