Structured Cell Renderer

Create your own custom schema on cell and render custom cells like Sparklines, document objects etc

The Structured Cell Renderer allows you to render custom visualizations and content within spreadsheet cells. Instead of displaying plain text, you can render rich content like sparklines, charts, or any custom component.

Overview

Structured results are special cell values that contain both data and rendering instructions. The spreadsheet automatically detects these structured values and renders them using the StructuredResultRenderer component.

Supported Structured Results

Sparklines

Sparklines are small inline charts that fit within a cell, perfect for visualizing trends in data.

import type { SparkLineResult } from "@rowsncolumns/common-types";

const sparklineValue: SparkLineResult = {
  kind: "sparkline",
  data: [1, 5, 3, 7, 4, 9, 6],
  formattedValue: "Trend", // Fallback text
};

The sparkline will automatically render as a mini chart within the cell.

Custom Structured Results

You can create your own structured result types by extending the StructuredResult interface:

Using Structured Cells

1. Define Your Custom Cell Data Type

2. Create Structured Cell Values

3. Custom Renderer (Optional)

If you need custom rendering logic beyond sparklines, you can provide your own StructuredResult component to CanvasGrid:

Getting Structured Values

You can access structured cell values through the spreadsheet state:

Formulas and Structured Results

You can create formulas that return structured results:

Complete Example

Use Cases

Sparklines are perfect for showing trends in financial data, metrics, or time series:

Custom Indicators

Create custom visual indicators for status, progress, or ratings:

Performance Considerations

  • Structured results are rendered using canvas (react-konva), providing excellent performance even with many cells

  • Complex visualizations should be optimized to avoid rendering bottlenecks

  • Consider using formattedValue as a text fallback for export and copy operations

Limitations

  • Structured results are visual-only and don't affect cell value calculations

  • When copying cells with structured results, the formattedValue is used as text

  • Excel export will show the formattedValue as plain text

Last updated

Was this helpful?