-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport.php
More file actions
42 lines (35 loc) · 1.25 KB
/
Copy pathexport.php
File metadata and controls
42 lines (35 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
// 简化的CSV导出,不依赖外部库
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename="森森信息部工作周报表_' . date('Y年m月d日') . '.csv"');
header('Cache-Control: max-age=0');
// 输出BOM以支持中文
echo "\xEF\xBB\xBF";
// 读取报告数据
$reports = [];
if (file_exists('reports.json')) {
$reports = json_decode(file_get_contents('reports.json'), true) ?: [];
}
// 输出CSV头部
echo "日期,姓名,本周工作内容,下周工作计划,遇到的问题,建议与改进,创建时间,更新时间\n";
// 按日期排序
ksort($reports);
// 输出数据
foreach ($reports as $date => $report) {
$row = [
$date,
'"' . str_replace('"', '""', $report['reporter_name'] ?? '') . '"',
'"' . str_replace('"', '""', $report['work_content'] ?? '') . '"',
'"' . str_replace('"', '""', $report['next_plan'] ?? '') . '"',
'"' . str_replace('"', '""', $report['issues'] ?? '') . '"',
'"' . str_replace('"', '""', $report['suggestions'] ?? '') . '"',
$report['created_at'] ?? '',
$report['updated_at'] ?? ''
];
echo implode(',', $row) . "\n";
}
// 如果没有数据
if (empty($reports)) {
echo "暂无数据\n";
}
?>