55 lines
1.8 KiB
Markdown
55 lines
1.8 KiB
Markdown
# Feature: Export
|
|
|
|
## Supported Formats
|
|
| Format | Package | Use case |
|
|
|--------|--------------|----------------------------------|
|
|
| CSV | `csv` | Spreadsheet import (Excel, etc.) |
|
|
| PDF | `pdf` | Printable report |
|
|
| JSON | `dart:convert` | Backup / data portability |
|
|
|
|
## CSV Schema
|
|
```
|
|
id,project,start_time,end_time,duration_seconds,note,tags
|
|
42,My Project,2026-07-01T08:00:00,2026-07-01T10:30:00,9000,"Standup",planning|backend
|
|
```
|
|
- Date format: ISO 8601
|
|
- Tags: pipe-separated within the cell
|
|
- Encoding: UTF-8 with BOM for Excel compatibility
|
|
|
|
## PDF Layout
|
|
1. Header: App name + export date + selected period
|
|
2. Summary table: Project | Total hours | % of total
|
|
3. Entries table: Date | Project | Duration | Note | Tags
|
|
4. Footer: Generated by Timetrack
|
|
|
|
Use `pw.Document` from the `pdf` package.
|
|
Render with `pw.Table`, `pw.Text`, `pw.Chart` (optional).
|
|
|
|
## JSON Schema
|
|
```json
|
|
{
|
|
"exportedAt": "2026-07-12T10:00:00Z",
|
|
"version": 1,
|
|
"projects": [ { "id": 1, "name": "...", "color": -16711936 } ],
|
|
"tags": [ { "id": 1, "name": "backend" } ],
|
|
"entries": [
|
|
{
|
|
"id": 42, "projectId": 1, "startTime": "...", "endTime": "...",
|
|
"durationSeconds": 9000, "note": "...", "tagIds": [1]
|
|
}
|
|
]
|
|
}
|
|
```
|
|
JSON export can be used as a full backup and re-imported in a future version.
|
|
|
|
## Share Flow
|
|
```dart
|
|
final file = await _buildExportFile(format); // write to temp dir
|
|
await Share.shareXFiles([XFile(file.path)], // share_plus
|
|
subject: 'Timetrack Export ${DateFormat.yMd().format(DateTime.now())}');
|
|
```
|
|
Always write to `getTemporaryDirectory()` — never to arbitrary paths.
|
|
|
|
## Export Scope
|
|
- User selects: date range + format + optional project filter
|
|
- Available from Settings screen and Reports screen (share button)
|