[ZEPPELIN-4407] Add copy to clipboard (TSV/CSV) for table results#5261
Merged
Conversation
added 2 commits
June 2, 2026 11:55
Adds "Copy as TSV" and "Copy as CSV" options to the table result export dropdown in both the Angular (zeppelin-web-angular) and classic AngularJS (zeppelin-web) UIs. - Header row (column names) is always included in the copied text - Cell values containing the delimiter, double-quotes, or newlines are RFC 4180 quoted automatically - Uses navigator.clipboard.writeText with a document.execCommand fallback for older browsers - In the Angular table visualization, "Copy visible data" copies only the currently filtered/paginated rows, matching the existing "Export visible" behaviour - Existing "CSV" / "TSV" download items renamed to "Download as CSV/TSV" for clarity Closes apache#3496 (original AngularJS-only implementation by @amakaur)
…s in tests Karma tests failed because spyOn(navigator.clipboard, 'writeText') was called twice — once in beforeEach and again inside two test bodies. Playwright tests failed because grantPermissions ran before the CI skip, and Firefox/WebKit reject unknown permissions (clipboard-read/clipboard-write).
tbonelee
requested changes
Jun 3, 2026
Contributor
tbonelee
left a comment
There was a problem hiding this comment.
Thanks for the suggestion.
Overall logics looks good to me, and I only left a few feedbacks.
You could also add a test cases which handles double quote delimiter in both zeppelin-web and zeppelin-web-angular
- Extract fallbackCopy function and guard navigator.clipboard existence in both result.component.ts and table-visualization.component.ts so the fallback works in plain HTTP (non-secure) contexts - Refactor result.controller.js: extract escape() closure shared by headers and cells; fix null/undefined cell value handling - Add test: header values containing double quotes are RFC 4180 quoted (classic UI Karma test + Angular E2E Playwright test)
tbonelee
approved these changes
Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR for?
I've seen users downloading CSV and opening in spreadsheet viewer and copying the text.
Adding way to copy CSV/TSV directly. This is orginally implemented by @amakaur #3496 but it was closed due to lack of tests. I'm picking it up now.
Changes
Angular UI (
zeppelin-web-angular)result.component— paragraph toolbar dropdown: renamed existing items to "Download as CSV/TSV", added divider, then "Copy as TSV" and "Copy as CSV"table-visualization.component— inner table Export menu: added "Copy all data as TSV/CSV" and "Copy visible data as TSV/CSV" (mirrors the existing "Export visible" scope)Classic AngularJS UI (
zeppelin-web)result-chart-selector.html— same dropdown restructure: Download / divider / Copyresult.controller.js— new$scope.copyToClipboard(delimiter)functionBehaviour
navigator.clipboard.writeTextwith adocument.execCommand('copy')fallback for older browsersWhat type of PR is it?
Feature
What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-4407
How should this be tested?
%sh printf "col1\tcol2\na\t1\nb\t2\n")"hello, world"→ the CSV copy should quote it correctlyTests
zeppelin-web/src/app/notebook/paragraph/result/result.controller.test.js— 4 new specs covering TSV copy, CSV copy, delimiter quoting, and double-quote escapingzeppelin-web-angular/e2e/tests/notebook/paragraph/copy-to-clipboard.spec.ts— 3 new specs (skipped on CI, require a live interpreter)Questions
screenshots