Skip to content

feat: add Excel (XLSX) export for task time entries#278

Open
2mcreations wants to merge 3 commits into
te-online:mainfrom
2mcreations:feature/export-task-xlsx
Open

feat: add Excel (XLSX) export for task time entries#278
2mcreations wants to merge 3 commits into
te-online:mainfrom
2mcreations:feature/export-task-xlsx

Conversation

@2mcreations

Copy link
Copy Markdown

Summary

Adds the ability to export all time entries of a specific task to an Excel (.xlsx) file, making it easy to share time tracking statistics with clients or colleagues outside of Nextcloud.

Changes

New file: lib/Helper/ArrayToXLSX.php

Pure PHP helper class that converts an array of time entries into a formatted .xlsx spreadsheet:

  • Bold, colored header row
  • Auto-sized columns
  • Automatic SUM formula on the duration column
  • No extra Composer dependencies (uses native PHP spreadsheet generation)

Modified: lib/Controller/PageController.php

  • Added use OCA\TimeManager\Helper\ArrayToXLSX;
  • Added exportTaskXlsx(string $task_uuid, string $timezone) method: fetches all time entries for the given task, resolves task/project/client names and author display names, respects the user's timezone and the input method setting (decimal vs. minutes), and returns a DataDownloadResponse with the .xlsx file
  • Extended reports() to also support format=xlsx (same data as CSV export, different format)

Modified: appinfo/routes.php

  • Added route: GET /times/export/xlsxpage#exportTaskXlsx

Modified: templates/times.php

  • Added an "Export Excel" button in the task detail header, visible whenever a task is selected
  • The button passes task_uuid and the user's server timezone to the export endpoint
  • Visible to all users (including read-only sharees), not just editors

Export columns

Column Description
date Entry date (Y-m-d)
start Start time (H:i)
end End time (H:i)
duration Hours (decimal or HH:MM depending on app setting)
note Entry note
status paid / unpaid
author Display name of the author
task Task name
project Project name
client Client name

2mcreations and others added 3 commits July 1, 2026 18:22
Adds a new endpoint GET /times/export/xlsx?task_uuid=<uuid>&timezone=<tz>
that exports all time entries for a specific task to an Excel file.

Changes:
- lib/Helper/ArrayToXLSX.php: new helper using native CSV-to-spreadsheet
  conversion via SpreadsheetWriter (pure PHP, no extra dependencies)
- lib/Controller/PageController.php: new exportTaskXlsx() method
- appinfo/routes.php: new route page#exportTaskXlsx
- templates/times.php: 'Export Excel' button in the task detail header
@te-online

te-online commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Hello! Thank you for contributing a PR 😊

I have a few questions/annotations:

  1. (a) Any details on why you added an export specifically to the task view? Perhaps users would rather create a report for specifically this task and export that one? I'm not sure if I want to provide this option so prominently, the button is also quite squished in currently with no clear alignment. It's probably important to your workflow otherwise you wouldn't have added it, but in my mind the UI should be simple for the average use case.

(b) You also don't seem to have put a button on the reports page to actually export to XLSX? I would expect the button to be there, next to the CSV button, instead of on the task page.

(c) Additionally, the columns of the reports export seems to be different from the columns of the task export. Is that on purpose?

  1. I think you may want to pass in the browser timezone instead of relying on the user setting. I usually only use that setting as a fallback if I don't have the browser timezone sent as a query param. It is, however, the browser timezone we use for time entries in the UI, since conversion is done in client-side JavaScript.

  2. You seem to have deleted some code from the page controller which didn't allow me to even load the app when checking out your branch. See my inline comment to see what is missing.

  3. Any specific reason you added styling to the spreadsheet? It doesn't seem necessary, since users can apply a template in Excel, I assume? This is not extremely important, but I'm just not sure if I want to provide any specific branding. I think I would prefer the spreadsheet to be entirely neutral (i.e. without background colors).

One last thing: I haven't defined a contributing guide, so don't take this the wrong way: Would you mind to disclose to which degree you've used LLM or taken inspiration from other repositories to create code in this PR (especially the ArrayToXLSX class)? It helps me evaluate if your PR could include code or snippets of other projects where I need to check the license before including in my project.

* @NoAdminRequired
* @NoCSRFRequired
*/
function settings(): TemplateResponse {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the settings controller as well as the getSettings method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants