text/csv
即可。,
」隔開;而 Calc 預設用「;
」隔開,且遇到文字需用雙引號"
包起來。templates\op_tad_signup_actions_show.tpl
加入匯出按鈕
<a href="<{$xoops_url}>/modules/tad_signup/csv.php?id=<{$id}>" class="btn btn-primary"><i class="fa fa-file-text-o" aria-hidden="true"></i> 匯出CSV</a>
csv.php
,先建一個匯入範例檔(就是只有標題沒有內容的檔案):
<?php
use Xmf\Request;
use XoopsModules\Tad_signup\Tad_signup_actions;
require_once __DIR__ . '/header.php';
if (!$_SESSION['can_add']) {
redirect_header($_SERVER['PHP_SELF'], 3, "您沒有權限使用此功能");
}
$id = Request::getInt('id');
$action = Tad_signup_actions::get($id);
if ($action['uid'] != $xoopsUser->uid()) {
redirect_header($_SERVER['PHP_SELF'], 3, "您沒有權限使用此功能");
}
$csv = [];
$head_row = explode("\n", $action['setup']);
$head = [];
foreach ($head_row as $head_data) {
$cols = explode(',', $head_data);
if (strpos($cols[0], '#') === false) {
$head[] = str_replace('*', '', trim($cols[0]));
}
}
$head[] = '錄取';
$head[] = '報名日期';
$head[] = '身份';
$csv[] = implode(',', $head);
$content = implode("\n", $csv);
$content = mb_convert_encoding($content, 'Big5');
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename= {$action['title']}報名名單.csv");
echo $content;
exit;
$head_row = explode("\n", $action['setup']);
$head = [];
foreach ($head_row as $head_data) {
$cols = explode(',', $head_data);
if (strpos($cols[0], '#') === false) {
$head[] = str_replace('*', '', trim($cols[0]));
}
}
$TadDataCenter = new TadDataCenter('tad_signup');
$head = $TadDataCenter->getAllColItems($action['setup']);
tadtools/class/TadDataCenter.php 必須是 2021/10/29 日以後的版本,可至此下載覆蓋
link to https://github.com/tadlearn/tad_signup/commit/1511364b797f1a615f849316ed26b345a1bd4e8c \