Skip to content

Changelog

Mondrian v1.14.0 adds JSF v2 support including themes, colour models, pattern fills, a callback for custom cell content rendering, and annotation markers for cells with comments or notes.

JSF v2 support: themes, colours, and pattern fills

Section titled “JSF v2 support: themes, colours, and pattern fills”

The renderer now handles JSF v2 workbook format changes, including theme colours and fonts, and cell background pattern fills.

A new onCellContent callback option lets you control how cell content is rendered. Return false from the callback to suppress the default rendering and draw your own content using the canvas context.

new Renderer({
onCellContent ({ cell, ctx, rect }) {
if (cell.value === 'logo') {
ctx.drawImage(logoImage, rect.x, rect.y, rect.width, rect.height);
return false; // suppress default rendering
}
},
});

Cells containing threaded comments or notes now display a small yellow triangle in the top-right corner. This is enabled by default and can be turned off with the showAnnotations option.

new Renderer({
showAnnotations: false,
});
  • Fix toMeasure returning wrong index for pixel positions within first cell on empty sheets
  • Add online documentation site
  • Dependency updates
  • Export types from package
  • Fix a left-over issue in setColumnSize
  • Fix StyleManager.get() to return Style | null
  • Allow table style name to be null
  • Include only required files in distributed package
  • Bump @borgar/xlsx-convert from 3.6.0 to 3.6.1
  • Dev dependency updates
  • Use latest version of Cellatrix
  • Updates to dependencies
  • Publish package to the npmjs.com registry
  • Remove dependence on Cellatrix types
  • Use local coordinates to draw error mark
  • Clip error mark drawing to small cell bounds
  • Updates to dependencies
  • Respect a workbook’s default style
  • Apply viewport offset to non-merged cell rects
  • Draw triangles in top-left of cells with errors
  • Fix sheet bounds check for merged cells
  • Tighten some types and type checks
  • Update to use Cellatrix v1.2.1
  • Add lint and typecheck jobs to CI workflow
  • Updates to dependencies

Mondrian v1.8.0 now comes with an API for resizing columns and rows, an option to render formulas when calculated values are missing, support for rendering tables, and support for CSV/TSV data sources.

Mondrian’s renderer now includes helper methods to get and set column widths and row heights.

const renderer = new Renderer();
renderer.setWorkbook(model.getWorkbook());
renderer.setSheet("Sheet1");
// Resize column D to 180px and row 11 to 32px
renderer.setColumnSize(3, 180);
renderer.setRowSize(10, 32);

Option to show formulas when calculated values are missing

Section titled “Option to show formulas when calculated values are missing”

When OpenPyXL (and other libraries without a full spreadsheet engine) creates cells with formulas, it will fail to include a calculated value in the cell. By default, those cells will render empty in the viewer. Now you can instantiate a renderer with showValuelessFormulas: true to render formulas instead of empty cells.

new Renderer({
showValuelessFormulas: true,
});

Mondrian’s renderer now applies Excel table styles end-to-end: headers, banded rows, emphasised columns, and totals rows all inherit the colours and borders defined on each table.

Workbooks loaded via xlsx-converter can come from CSV/TSV sources.

import { readFile } from "node:fs/promises";
import { convertCSV } from "@borgar/xlsx-convert";
import { Model } from "@grid-is/cellatrix";
import { Renderer } from "@grid-is/mondrian";
const csv = await readFile("./data.csv", "utf8");
const jsf = convertCSV(csv, "data.csv");
const model = Model.fromJSF(jsf);
const renderer = new Renderer();
renderer.setWorkbook(model.getWorkbook());
renderer.setSheet("Sheet1");
  • Add support for rendering tables
  • Bump @borgar/xlsx-convert from 3.3.2 to 3.4.0
  • Bump typescript-eslint from 8.44.0 to 8.44.1
  • Bump skia-canvas from 3.0.6 to 3.0.7
  • Bump @grid-is/cellatrix from 1.0.0-rc11 to 1.1.0
  • Bump eslint from 9.35.0 to 9.36.0
  • Point default export at built index.js
  • Use color from number format if it exists
  • Add GitHub Actions workflow for automatic releases
  • Prevent failure when col/row default sizes are zero
  • Support dragging-and-dropping workbooks onto browser viewer example
  • Respect header spans in rectToRanges
  • Improve render tests
  • Run unit tests in a CI workflow
  • Translate project to Typescript