EXAMPLES
Links and cell images
Supports automatic link detection, column image renderers, and per-cell images.
Automatic link detection
A complete URL or email address, after trimming whitespace, appears as a blue underlined link and opens in a new tab when clicked. Embedded URLs in longer text are not detected. Detection does not change the stored value or require a column type or renderer.
sheet.setCell(row, column, "https://www.cyexcel.example/products/CY-000001"); // A complete URL is detected as a clickable link.
Column image renderer
Set a column's renderer to createImageCellRenderer() to display HTTP(S) URLs or data: URIs as images. Images are centered and scaled proportionally without cropping. Use this for columns of image addresses. An image file extension alone does not make ordinary text render as an image.
import { createImageCellRenderer } from "cyexcel/core";
const columns = [
{ width: 72, header: "Image", renderer: createImageCellRenderer() }
// ...
];
sheet.setCell(row, column, "https://example.com/avatar.png");Per-cell images
setCellImage() and getCellImage() set and read per-cell images without a column renderer. Text and images can coexist in the same column. A cell image takes priority over the column renderer. Pass undefined to remove an image without changing the cell value (v) or style (s).
const columns = [
{ width: 72, header: "Image" }
// No renderer needed; other cells in the column retain their default rendering.
];
// Set an image only for the specified cell.
sheet.setCellImage(row, column, "https://example.com/avatar.png");
// Clear
sheet.setCellImage(row, column, undefined);Links and images example
The Website column demonstrates URL detection. Image (column renderer) uses createImageCellRenderer(). Image (cell property) uses setCellImage() for rows 1 and 3.