Make exported case numbers clickable and visibly styled hyperlinks using ExcelJS in XLSX export#172
Make exported case numbers clickable and visibly styled hyperlinks using ExcelJS in XLSX export#172
Conversation
Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
|
@copilot Instead of adding a column with the portal URL for the case, make the case number a clickable hyperlink. Text should remain the case number, and if there is a portal case number (case was found in the portal), then associate it with the portal URL and make it a hyperlink. |
Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Updated in commit c610aac. The export now keeps the displayed text as the case number and applies the hyperlink directly to the Case Number cell when a portal caseId exists. I removed the added Case URL column and adjusted the export tests accordingly. |
|
@copilot It looks like the feature works, but there is no visual identifier in the spreadsheet to indicate that there are hyperlinks. Does the styling need to be applied, explicitly or is there a default that can be used? I'd expect blue, underlined text for hyperlinks and the standard text style, if not. |
Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Implemented in commit d804010. I now explicitly apply hyperlink font styling on linked Case Number cells ( |
|
@copilot I deployed these changes , but the case number links still did not show link-like formatting. |
Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Updated in commit ff31b0c. I switched linked case-number cells to use an Excel |
|
@copilot I see the HYPERLINK formula, but the text is still not formatted. |
Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Updated in commit 6d481cc. I now keep the |
|
@copilot Excel doesn’t automatically style hyperlinks unless they are actual cell hyperlink relationships. The default open-source/community xlsx package does not reliably write cell styles (cell.s). Styling (color/underline) in the community version has no effect unless using a styling-enabled fork or SheetJS Pro. ✔️ Task Generate instructions and example code for: Correctly adding real hyperlinks via the l property (Hyperlink Relationship) instead of using an HYPERLINK formula. (If applicable) optionally mention a styling-capable package like xlsx-js-style if the user needs custom visual styling. 🧾 Instructions to Generate Your reply must include:
State that SheetJS stores hyperlink targets in the cell object’s l key. Note that Excel doesn’t automatically apply hyperlink formatting, and styling in the community xlsx package is not supported. Example explanation: In SheetJS, a hyperlink is defined on a cell via the ws["A1"].l = { Target: "https://example.com" };
Excel will recognize the hyperlink and make the cell clickable, but the default open-source writer does not reliably write visible styles (blue/underline).
---
### **2) Correct code pattern (preferred)**
Replace your current formula + styling approach with:
```js
const cellRef = XLSX.utils.encode_cell({ r: row, c: caseNumberColumn });
const cell = ws[cellRef];
if (cell && caseUrl) {
cell.t = "s"; // text cell
cell.v = caseNumber; // display the case number
delete cell.f; // remove any formula
cell.l = { Target: caseUrl }; // set hyperlink relationship
}
3) Optional: Use a style-capable package
If the user must visually style hyperlinks (e.g., blue + underline), include instructions to install and use a SheetJS fork with style support like xlsx-js-style:
npm install xlsx-js-style
Then generate a styled hyperlink cell:
cell.s = {
font: { color: { rgb: "FF0563C1" }, underline: true }
};
Mention that this package does write styles to the file, unlike the community xlsx package.
4) Summary or troubleshooting tips
Add a short note like:
Don’t mix l and f for the same cell. Use one method (prefer l).
If styles still don’t appear, use the styling fork or SheetJS Pro.
🟡 Final Deliverable
Your output should be formatted like:
A short explanation of the issue
Correct code snippet(s)
Optional instructions for styling support
One or two brief bullet summary tips
That’s it — generate concise, clear, correctness-focused instructions for the user. |
Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Implemented in commit 5d7356d. The export now uses real SheetJS hyperlink relationships ( const cellRef = XLSX.utils.encode_cell({ r: row, c: caseNumberColumn });
const cell = ws[cellRef];
if (cell && caseUrl) {
cell.t = 's';
cell.v = caseNumber;
delete cell.f;
cell.l = { Target: caseUrl };
}If you need guaranteed visual styling in output files, use a styling-capable package (e.g. npm install xlsx-js-stylecell.s = {
font: { color: { rgb: 'FF0563C1' }, underline: true }
};Tips:
|
|
@copilot Okay, well the community version of sheetjs does not support styling. |
Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Implemented in commit 39ba960. Export generation is now reimplemented with
I also updated dependency/lock files and rewrote the export handler tests to mock and validate the ExcelJS workbook API behavior. |

Case export already produced
.xlsx, but hyperlink styling was not reliable with the SheetJS community writer. This update reimplements export workbook generation with ExcelJS to preserve clickable hyperlinks and visible hyperlink formatting in Excel.Library migration
exceljsas a serverless dependency and updated lockfile.Export behavior preserved
Cases), filename format, response headers, and base64 download behavior.Case URLcolumn.Hyperlink implementation in ExcelJS
cell.value = { text: caseNumber, hyperlink: caseUrl }FF0563C1)true)Column sizing preserved
Focused export test coverage updated
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.