【问题标题】:How to print fullcalendar with given date range including all events?如何打印包含所有事件的给定日期范围的完整日历?
【发布时间】:2020-02-05 14:43:20
【问题描述】:

如何打印完整日历或以 PDF 或 Excel 格式导出完整日历?

例如:

输入:

开始日期:2020 年 1 月 1 日

结束日期:2020 年 12 月 31 日

点击按钮后,它将获取给定日期范围内的所有事件并将其填充到fullcalendar

会有类似...

  1. 2020 年 1 月 26 日将举办活动 - 澳大利亚日

  2. 2020 年 2 月 14 日将举办活动 - 情人节

  3. ...

  4. ...

  5. 2020 年 12 月 25 日将举办活动 - 圣诞节

如您所见,不同月份会有多个事件,而我正在寻找的是在单个页面中打印或导出这个完整的日历,包含所有 12 个月份。

您的回复将帮助很多人。

【问题讨论】:

  • 您想要 1) 显示所有日期的实际日历布局,并在事件发生的日期显示事件,或者 2) 只是事件列表?根据您的描述和事件样本,这有点不清楚。
  • (顺便说一句,第 2 版非常可实现 - 只需使用具有合适可见范围/持续时间的“列表”视图。用户可以打开它,然后在浏览器中单击“打印”,他们应该能够“打印”到 PDF。如果您想要 Excel 导出,那么最好通过直接从服务器获取事件数据来做到这一点。FullCalendar 不需要参与这样的数据驱动过程。)
  • 第一个选项实际日历布局
  • 第 1 版实现起来要困难得多。我认为您需要 a) 一些 JavaScript 来自动将月视图从一个月更改为另一个月,直到您涵盖所有年份,然后 b) 在其中添加一些 JavaScript,每个月都会转换当前显示的 HTML /CSS 在内存中转换为 pdf 格式 - 可能有某种库可以做到这一点。您必须将每个捕获月份的所有数据连接到一个 PDF 文档中。据我所知,将这种可视化布局导出到 Excel 没有任何意义,所以不知道你为什么要这样做。)
  • (如果您一次只需要一个月的数据在您的 PDF 中,它会容易得多 - 只需要求用户按打印,然后另存为 PDF)。很难 12 个月的原因是 fullCalendar 没有内置的“全年”布局。 TBH,如果它只是像这样只读,实际上可能更容易生成自己的 HTML 表。

标签: javascript jquery fullcalendar fullcalendar-4


【解决方案1】:

您可以通过编辑使用下面的示例代码,希望对您有所帮助

<?php

header("Content-Type: text/html; charset=iso-8859-9");
header("Content-Type: text/html; charset=windows-1254");
header("Content-Type: text/html; charset=x-mac-turkish");

$today = date("d-m-Y");

// Defines the name of the export file "codelution-export.xls" 
header("Content-Disposition: attachment; filename=$today-BOOK.xls");

$date = '2020-05-01';

//get end date of month
$end = '2020-05-' . date('t', strtotime($date));


include("../../DATABASE.php");
?>

<table>
  <tr>
    <td>PERSONAL</td>

    <?php
      while(strtotime($date) <= strtotime($end)){
        $day_num = date('d', strtotime($date));
        $day_name = date('l', strtotime($date));
        $date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
        echo "<td>$day_num <br/> $day_name</td>";
      }
    ?>
  </tr>

  <?php
    //get end date of month
    $hsql=mysql_query("select * from XXXUSER"); 
    while($hyaz=mysql_fetch_array($hsql)){
      $firstname=$hyaz["firstname"];
      $kullanicidi=$hyaz["id"];
      echo "<tr>";
      echo "<td>$firstname</td>";
      $fromdate = '2020-06-01';
      $todate = '2020-06-' . date('t', strtotime($fromdate));

      while(strtotime($fromdate) <= strtotime($todate)) {
        $geneltarih = date('Y-m-d', strtotime($fromdate));
        $fromdate = date("Y-m-d", strtotime("+1 day",strtotime($fromdate)));
        $xxxsql = mysql_fetch_array(mysql_query("select * from XXXSCHEDULE where kaynakcodu='$kullanicidi' and start_event='$geneltarih'")); 
        $title = $xxxsql["title"];
        echo " <td>$title</td>";
      }

      echo "</tr>";
    }
  ?>
</table>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多