Skip to content

Adds Excel export and copying cells in the grid - #608

Open
andreas-prouza wants to merge 2 commits into
codefori:mainfrom
andreas-prouza:main
Open

andreas-prouza wants to merge 2 commits into
codefori:mainfrom
andreas-prouza:main

Conversation

@andreas-prouza

@andreas-prouza andreas-prouza commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Changes

This PR adds two ways to get data out of a result set:

  • export to Excel
  • and selecting and copying cells in the grid.

Export as Excel

  • New Export as Excel entry in the result set's Export as... menu (results view and editor tabs), next to CSV.
  • When not all rows are loaded yet, it asks whether to export all rows or only the loaded ones, the same as the other formats.
  • A checklist chooses the header rows written above the data: Column names and/or Column descriptions (the column labels). The last choice is remembered.
  • If a result set has no column descriptions, that option is inactive and says why ('Extended metadata' must be enabled in the JDBC configuration).
  • A save dialog suggests a file name from the result title or table name. After saving, the file can be opened or revealed in the file explorer.
  • Workbook details:
    • Header rows are bold and frozen, with filter buttons on the last header row. Column widths fit the content.
    • Numbers are stored as numbers, including DECIMAL/BIGINT values the server returns as strings. Values with more than 15 digits stay text so Excel does not round them. CHAR values such as 00123 keep their leading zeros.
    • NULLs are empty cells. Exports over Excel's row limit (1,048,576) are refused with a message.
  • The .xlsx file is written by a small built-in writer (src/views/results/excel.ts, using Node's zlib), so no new dependency is added.

Select and copy cells in the grid

  • Click selects a cell. Drag or Shift+click selects a block, Ctrl/Cmd+click adds or removes a cell, Ctrl/Cmd+A selects every loaded row, and Escape clears the selection.
  • Ctrl/Cmd+C copies the selection as tab-separated text, so it pastes into Excel/Calc cells. Values containing tabs, line breaks or quotes are quoted, and NULLs copy as empty cells.
  • Right-clicking adds Copy and Copy with Headers to the grid's context menu, alongside existing row actions such as Delete Row.
  • Text selected inside a single cell is still copied as plain text.
  • In updatable result sets, a plain click still edits the cell. Shift+click, Ctrl+click and dragging select without editing.
  • The selection clears when sorting, searching or rerunning the query, and follows the columns when they are moved.
  • This is implemented in the shared data table, so it also works in the other tables built on it (for example index advice).

How to test this PR

  1. Run the unit tests: npm test (includes the new excel.test.ts).
  2. Run a query, e.g. select * from qsys2.sysschemas.

Excel export

  1. In the result set toolbar, open Export as... → Export as Excel.
  2. Keep Column names checked, save the file and open it. Check the bold, frozen header row, the filter buttons and that numeric columns are numbers.
  3. With 'Extended metadata' enabled in the JDBC configuration, run a query on a table with column labels and export again with Column descriptions checked. A second header row with the labels appears.
  4. Without extended metadata, the Column descriptions option is inactive and cannot be checked.
  5. Run a query that returns more rows than are loaded, export, and choose All rows. The file contains every row.

Cell selection and copy

  1. Click a cell, drag across several cells and Shift+click to extend. The selected cells are highlighted.
  2. Press Ctrl/Cmd+C and paste into Excel or Calc. The values land in separate cells.
  3. Right-click a cell → Copy with Headers and paste. The column titles come first.
  4. Ctrl/Cmd+click two cells in different rows and columns, copy and paste. They stay aligned, with blanks between them.
  5. Run an updatable query (update: prefix). A plain click still edits the cell; Shift+click and Ctrl+click only select. The row context menu still shows Delete Row next to the copy entries.

Checklist

  • have tested my change
  • have created one or more test cases
  • updated relevant documentation
  • Remove any/all console.logs I added
  • have added myself to the contributors' list in CONTRIBUTING.md

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.

1 participant