표 위에 제목 줄 넣기Add a title above the table
표 밖 칸에 제목과 작성일을 쓰고 표를 몇 줄 아래에서 시작해 내려받아요.Write a title and date outside the table and start the table a few rows lower.
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
이 화면은 새 모양 옵션을 켠 모양이에요: density: 'spacious', iconStyle: 'soft', motion: true (코드에 없으면 기본 모양으로 보여요)This preview has the new-look options on: density: 'spacious', iconStyle: 'soft', motion: true (without them in your code you get the default look)
이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i maxgrid @maxgrid/export로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div class="toolbar">
<input type="text" aria-label="제목" placeholder="제목 (비우면 기본)" id="title" />
<select aria-label="표 시작 줄" id="start">
<option value="r1">1줄 (겹침 오류)</option>
<option value="r3" selected>3줄</option>
<option value="r5">5줄</option>
</select>
<button type="button" id="download">내려받기</button>
</div>
<div id="grid" style="height: 300px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('title').addEventListener('input', (event) => actions.title(api, event.target.value));
document.getElementById('start').addEventListener('change', (event) => actions.start(api, event.target.value));
document.getElementById('download').addEventListener('click', () => actions.download(api));import { withExport } from '@maxgrid/export';
const regions = ['서울', '부산', '대전', '광주', '인천'];
const rows = regions.map((region, i) => ({
id: i + 1,
region,
sales: 8200 + i * 1350,
target: 9000 + i * 900,
}));
export const options = {
columns: [
{ id: 'region', title: '지역', width: 100 },
{ id: 'sales', title: '매출(만원)', kind: 'number', width: 110, align: 'end' },
{ id: 'target', title: '목표(만원)', kind: 'number', width: 110, align: 'end' },
],
rows,
rowKey: 'id',
};
let title = '지역별 매출 보고';
let startRow = 3;
let say = () => { };
export const actions = {
title: (_api, v) => void (title = (v ?? '').trim() || '지역별 매출 보고'),
start: (_api, v) => void (startRow = Number((v ?? 'r3').slice(1))),
download: async (api) => {
const ex = withExport(api);
// 제목·작성일은 표 밖 칸이에요. startRow가 3보다 작으면 표와 겹쳐서 오류가 나요.
const o = {
startRow,
extraCells: [
{ ref: 'A1', value: title, style: { bold: true, color: '#1F4E79', fill: '#DDEBF7' } },
{ ref: 'A2', value: new Date(2026, 10, 25), style: { numFmt: 'yyyy-mm-dd' } },
],
};
try {
await ex.downloadXlsx('매출-제목.xlsx', o);
say({
ko: `내려받았어요. 제목 A1 · 작성일 A2 · 표는 ${startRow}줄부터`,
en: `Downloaded. Title A1 · date A2 · table starts at row ${startRow}`,
});
}
catch (e) {
say({
ko: `내려받지 못했어요: ${e.message}`,
en: `Could not download: ${e.message}`,
});
}
},
};
export function setup(api, log) {
say = log;
withExport(api);
log({
ko: '표 위 1·2줄에 제목과 작성일을 쓰고 표는 3줄부터 시작해요. 시작 줄을 1로 바꾸면 겹침 오류를 볼 수 있어요.',
en: 'A title and date go in rows 1 and 2 and the table starts at row 3. Set the start row to 1 to see the overlap error.',
});
} 이 HTML은 추가 번들(위 script 태그)도 함께 불러오고 전역 변수로 써요. 별도 설치는 필요 없어요.
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>표 위에 제목 줄 넣기</title>
</head>
<body>
<div class="toolbar">
<input type="text" aria-label="제목" placeholder="제목 (비우면 기본)" id="title" />
<select aria-label="표 시작 줄" id="start">
<option value="r1">1줄 (겹침 오류)</option>
<option value="r3" selected>3줄</option>
<option value="r5">5줄</option>
</select>
<button type="button" id="download">내려받기</button>
</div>
<div id="grid" style="height: 300px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.export.min.js"></script>
<script>
const { withExport } = MaxGridExport;
const regions = ['서울', '부산', '대전', '광주', '인천'];
const rows = regions.map((region, i) => ({
id: i + 1,
region,
sales: 8200 + i * 1350,
target: 9000 + i * 900,
}));
const options = {
columns: [
{ id: 'region', title: '지역', width: 100 },
{ id: 'sales', title: '매출(만원)', kind: 'number', width: 110, align: 'end' },
{ id: 'target', title: '목표(만원)', kind: 'number', width: 110, align: 'end' },
],
rows,
rowKey: 'id',
};
let title = '지역별 매출 보고';
let startRow = 3;
let say = () => { };
const actions = {
title: (_api, v) => void (title = (v ?? '').trim() || '지역별 매출 보고'),
start: (_api, v) => void (startRow = Number((v ?? 'r3').slice(1))),
download: async (api) => {
const ex = withExport(api);
// 제목·작성일은 표 밖 칸이에요. startRow가 3보다 작으면 표와 겹쳐서 오류가 나요.
const o = {
startRow,
extraCells: [
{ ref: 'A1', value: title, style: { bold: true, color: '#1F4E79', fill: '#DDEBF7' } },
{ ref: 'A2', value: new Date(2026, 10, 25), style: { numFmt: 'yyyy-mm-dd' } },
],
};
try {
await ex.downloadXlsx('매출-제목.xlsx', o);
say({
ko: `내려받았어요. 제목 A1 · 작성일 A2 · 표는 ${startRow}줄부터`,
en: `Downloaded. Title A1 · date A2 · table starts at row ${startRow}`,
});
}
catch (e) {
say({
ko: `내려받지 못했어요: ${e.message}`,
en: `Could not download: ${e.message}`,
});
}
},
};
function setup(api, log) {
say = log;
withExport(api);
log({
ko: '표 위 1·2줄에 제목과 작성일을 쓰고 표는 3줄부터 시작해요. 시작 줄을 1로 바꾸면 겹침 오류를 볼 수 있어요.',
en: 'A title and date go in rows 1 and 2 and the table starts at row 3. Set the start row to 1 to see the overlap error.',
});
}
options.ariaLabel = "표 위에 제목 줄 넣기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('title').addEventListener('input', (event) => actions.title(api, event.target.value));
document.getElementById('start').addEventListener('change', (event) => actions.start(api, event.target.value));
document.getElementById('download').addEventListener('click', () => actions.download(api));
</script>
</body>
</html> 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/react @maxgrid/export로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<input
type="text"
aria-label="제목"
placeholder="제목 (비우면 기본)"
disabled={!api}
onChange={(event) => api && actions.title(api, event.target.value)}
/>
<select
aria-label="표 시작 줄"
disabled={!api}
onChange={(event) => api && actions.start(api, event.target.value)}
>
<option value="r1">1줄 (겹침 오류)</option>
<option value="r3">3줄</option>
<option value="r5">5줄</option>
</select>
<button
type="button"
disabled={!api}
onClick={() => api && actions.download(api)}
>내려받기</button>
</div>
<Grid style={{ height: 300 }} ref={gridRef} options={options} />
</>
);
}import { withExport } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
region: string;
sales: number;
target: number;
}
const regions = ['서울', '부산', '대전', '광주', '인천'];
const rows: Row[] = regions.map((region, i) => ({
id: i + 1,
region,
sales: 8200 + i * 1350,
target: 9000 + i * 900,
}));
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: '지역', width: 100 },
{ id: 'sales', title: '매출(만원)', kind: 'number', width: 110, align: 'end' },
{ id: 'target', title: '목표(만원)', kind: 'number', width: 110, align: 'end' },
],
rows,
rowKey: 'id',
};
let title = '지역별 매출 보고';
let startRow = 3;
let say: (message: LogText) => void = () => {};
export const actions = {
title: (_api: GridApi<Row>, v?: string) => void (title = (v ?? '').trim() || '지역별 매출 보고'),
start: (_api: GridApi<Row>, v?: string) => void (startRow = Number((v ?? 'r3').slice(1))),
download: async (api: GridApi<Row>) => {
const ex = withExport(api);
// 제목·작성일은 표 밖 칸이에요. startRow가 3보다 작으면 표와 겹쳐서 오류가 나요.
const o = {
startRow,
extraCells: [
{ ref: 'A1', value: title, style: { bold: true, color: '#1F4E79', fill: '#DDEBF7' } },
{ ref: 'A2', value: new Date(2026, 10, 25), style: { numFmt: 'yyyy-mm-dd' } },
],
};
try {
await ex.downloadXlsx('매출-제목.xlsx', o);
say({
ko: `내려받았어요. 제목 A1 · 작성일 A2 · 표는 ${startRow}줄부터`,
en: `Downloaded. Title A1 · date A2 · table starts at row ${startRow}`,
});
} catch (e) {
say({
ko: `내려받지 못했어요: ${(e as Error).message}`,
en: `Could not download: ${(e as Error).message}`,
});
}
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
withExport(api);
log({
ko: '표 위 1·2줄에 제목과 작성일을 쓰고 표는 3줄부터 시작해요. 시작 줄을 1로 바꾸면 겹침 오류를 볼 수 있어요.',
en: 'A title and date go in rows 1 and 2 and the table starts at row 3. Set the start row to 1 to see the overlap error.',
});
} 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/vue @maxgrid/export로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<input
type="text"
aria-label="제목"
placeholder="제목 (비우면 기본)"
:disabled="!api"
@input="api && actions.title(api, ($event.target as HTMLInputElement).value)"
/>
<select
aria-label="표 시작 줄"
:disabled="!api"
@change="api && actions.start(api, ($event.target as HTMLSelectElement).value)"
>
<option value="r1">1줄 (겹침 오류)</option>
<option value="r3" selected>3줄</option>
<option value="r5">5줄</option>
</select>
<button
type="button"
:disabled="!api"
@click="api && actions.download(api)"
>내려받기</button>
</div>
<Grid style="height: 300px" :options="options" @ready="onReady" />
</template>import { withExport } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
region: string;
sales: number;
target: number;
}
const regions = ['서울', '부산', '대전', '광주', '인천'];
const rows: Row[] = regions.map((region, i) => ({
id: i + 1,
region,
sales: 8200 + i * 1350,
target: 9000 + i * 900,
}));
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: '지역', width: 100 },
{ id: 'sales', title: '매출(만원)', kind: 'number', width: 110, align: 'end' },
{ id: 'target', title: '목표(만원)', kind: 'number', width: 110, align: 'end' },
],
rows,
rowKey: 'id',
};
let title = '지역별 매출 보고';
let startRow = 3;
let say: (message: LogText) => void = () => {};
export const actions = {
title: (_api: GridApi<Row>, v?: string) => void (title = (v ?? '').trim() || '지역별 매출 보고'),
start: (_api: GridApi<Row>, v?: string) => void (startRow = Number((v ?? 'r3').slice(1))),
download: async (api: GridApi<Row>) => {
const ex = withExport(api);
// 제목·작성일은 표 밖 칸이에요. startRow가 3보다 작으면 표와 겹쳐서 오류가 나요.
const o = {
startRow,
extraCells: [
{ ref: 'A1', value: title, style: { bold: true, color: '#1F4E79', fill: '#DDEBF7' } },
{ ref: 'A2', value: new Date(2026, 10, 25), style: { numFmt: 'yyyy-mm-dd' } },
],
};
try {
await ex.downloadXlsx('매출-제목.xlsx', o);
say({
ko: `내려받았어요. 제목 A1 · 작성일 A2 · 표는 ${startRow}줄부터`,
en: `Downloaded. Title A1 · date A2 · table starts at row ${startRow}`,
});
} catch (e) {
say({
ko: `내려받지 못했어요: ${(e as Error).message}`,
en: `Could not download: ${(e as Error).message}`,
});
}
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
withExport(api);
log({
ko: '표 위 1·2줄에 제목과 작성일을 쓰고 표는 3줄부터 시작해요. 시작 줄을 1로 바꾸면 겹침 오류를 볼 수 있어요.',
en: 'A title and date go in rows 1 and 2 and the table starts at row 3. Set the start row to 1 to see the overlap error.',
});
} 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/angular @maxgrid/export로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<input
type="text"
aria-label="제목"
placeholder="제목 (비우면 기본)"
[disabled]="!api"
(input)="api && actions.title(api, $any($event.target).value)"
/>
<select
aria-label="표 시작 줄"
[disabled]="!api"
(change)="api && actions.start(api, $any($event.target).value)"
>
<option value="r1">1줄 (겹침 오류)</option>
<option value="r3" selected>3줄</option>
<option value="r5">5줄</option>
</select>
<button
type="button"
[disabled]="!api"
(click)="api && actions.download(api)"
>내려받기</button>
</div>
<mx-grid style="height: 300px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import { withExport } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
region: string;
sales: number;
target: number;
}
const regions = ['서울', '부산', '대전', '광주', '인천'];
const rows: Row[] = regions.map((region, i) => ({
id: i + 1,
region,
sales: 8200 + i * 1350,
target: 9000 + i * 900,
}));
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: '지역', width: 100 },
{ id: 'sales', title: '매출(만원)', kind: 'number', width: 110, align: 'end' },
{ id: 'target', title: '목표(만원)', kind: 'number', width: 110, align: 'end' },
],
rows,
rowKey: 'id',
};
let title = '지역별 매출 보고';
let startRow = 3;
let say: (message: LogText) => void = () => {};
export const actions = {
title: (_api: GridApi<Row>, v?: string) => void (title = (v ?? '').trim() || '지역별 매출 보고'),
start: (_api: GridApi<Row>, v?: string) => void (startRow = Number((v ?? 'r3').slice(1))),
download: async (api: GridApi<Row>) => {
const ex = withExport(api);
// 제목·작성일은 표 밖 칸이에요. startRow가 3보다 작으면 표와 겹쳐서 오류가 나요.
const o = {
startRow,
extraCells: [
{ ref: 'A1', value: title, style: { bold: true, color: '#1F4E79', fill: '#DDEBF7' } },
{ ref: 'A2', value: new Date(2026, 10, 25), style: { numFmt: 'yyyy-mm-dd' } },
],
};
try {
await ex.downloadXlsx('매출-제목.xlsx', o);
say({
ko: `내려받았어요. 제목 A1 · 작성일 A2 · 표는 ${startRow}줄부터`,
en: `Downloaded. Title A1 · date A2 · table starts at row ${startRow}`,
});
} catch (e) {
say({
ko: `내려받지 못했어요: ${(e as Error).message}`,
en: `Could not download: ${(e as Error).message}`,
});
}
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
withExport(api);
log({
ko: '표 위 1·2줄에 제목과 작성일을 쓰고 표는 3줄부터 시작해요. 시작 줄을 1로 바꾸면 겹침 오류를 볼 수 있어요.',
en: 'A title and date go in rows 1 and 2 and the table starts at row 3. Set the start row to 1 to see the overlap error.',
});
} This example needs an extra package. To run it locally, install with npm i maxgrid @maxgrid/export.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<input
type="text"
aria-label="Title"
placeholder="Title (blank = default)"
id="title"
/>
<select aria-label="Table start row" id="start">
<option value="r1">Row 1 (overlap error)</option>
<option value="r3" selected>Row 3</option>
<option value="r5">Row 5</option>
</select>
<button type="button" id="download">Download</button>
</div>
<div id="grid" style="height: 300px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('title').addEventListener('input', (event) => actions.title(api, event.target.value));
document.getElementById('start').addEventListener('change', (event) => actions.start(api, event.target.value));
document.getElementById('download').addEventListener('click', () => actions.download(api));import { withExport } from '@maxgrid/export';
const regions = ['New York', 'Chicago', 'Dallas', 'Denver', 'Seattle'];
const rows = regions.map((region, i) => ({
id: i + 1,
region,
sales: (8200 + i * 1350) / 1000,
target: (9000 + i * 900) / 1000,
}));
export const options = {
columns: [
{ id: 'region', title: 'Region', width: 100 },
{ id: 'sales', title: 'Sales ($K)', kind: 'number', width: 110, align: 'end' },
{ id: 'target', title: 'Target ($K)', kind: 'number', width: 110, align: 'end' },
],
rows,
rowKey: 'id',
};
let title = 'Sales by region';
let startRow = 3;
let say = () => { };
export const actions = {
title: (_api, v) => void (title = (v ?? '').trim() || 'Sales by region'),
start: (_api, v) => void (startRow = Number((v ?? 'r3').slice(1))),
download: async (api) => {
const ex = withExport(api);
// The title and date are cells outside the table. A startRow below 3 overlaps the table and throws.
const o = {
startRow,
extraCells: [
{ ref: 'A1', value: title, style: { bold: true, color: '#1F4E79', fill: '#DDEBF7' } },
{ ref: 'A2', value: new Date(2026, 10, 25), style: { numFmt: 'yyyy-mm-dd' } },
],
};
try {
await ex.downloadXlsx('sales-title.xlsx', o);
say(`Downloaded. Title A1 · date A2 · table starts at row ${startRow}`);
}
catch (e) {
say(`Could not download: ${e.message}`);
}
},
};
export function setup(api, log) {
say = log;
withExport(api);
log('A title and date go in rows 1 and 2 and the table starts at row 3. Set the start row to 1 to see the overlap error.');
}This HTML also loads an extra bundle (the extra script tag above) and uses it as a global. No install is needed.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Add a title above the table</title>
</head>
<body>
<div class="toolbar">
<input
type="text"
aria-label="Title"
placeholder="Title (blank = default)"
id="title"
/>
<select aria-label="Table start row" id="start">
<option value="r1">Row 1 (overlap error)</option>
<option value="r3" selected>Row 3</option>
<option value="r5">Row 5</option>
</select>
<button type="button" id="download">Download</button>
</div>
<div id="grid" style="height: 300px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.export.min.js"></script>
<script>
const { withExport } = MaxGridExport;
const regions = ['New York', 'Chicago', 'Dallas', 'Denver', 'Seattle'];
const rows = regions.map((region, i) => ({
id: i + 1,
region,
sales: (8200 + i * 1350) / 1000,
target: (9000 + i * 900) / 1000,
}));
const options = {
columns: [
{ id: 'region', title: 'Region', width: 100 },
{ id: 'sales', title: 'Sales ($K)', kind: 'number', width: 110, align: 'end' },
{ id: 'target', title: 'Target ($K)', kind: 'number', width: 110, align: 'end' },
],
rows,
rowKey: 'id',
};
let title = 'Sales by region';
let startRow = 3;
let say = () => { };
const actions = {
title: (_api, v) => void (title = (v ?? '').trim() || 'Sales by region'),
start: (_api, v) => void (startRow = Number((v ?? 'r3').slice(1))),
download: async (api) => {
const ex = withExport(api);
// The title and date are cells outside the table. A startRow below 3 overlaps the table and throws.
const o = {
startRow,
extraCells: [
{ ref: 'A1', value: title, style: { bold: true, color: '#1F4E79', fill: '#DDEBF7' } },
{ ref: 'A2', value: new Date(2026, 10, 25), style: { numFmt: 'yyyy-mm-dd' } },
],
};
try {
await ex.downloadXlsx('sales-title.xlsx', o);
say(`Downloaded. Title A1 · date A2 · table starts at row ${startRow}`);
}
catch (e) {
say(`Could not download: ${e.message}`);
}
},
};
function setup(api, log) {
say = log;
withExport(api);
log('A title and date go in rows 1 and 2 and the table starts at row 3. Set the start row to 1 to see the overlap error.');
}
options.ariaLabel = "Add a title above the table";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('title').addEventListener('input', (event) => actions.title(api, event.target.value));
document.getElementById('start').addEventListener('change', (event) => actions.start(api, event.target.value));
document.getElementById('download').addEventListener('click', () => actions.download(api));
</script>
</body>
</html> This example needs an extra package. To run it locally, install with npm i @maxgrid/react @maxgrid/export.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<input
type="text"
aria-label="Title"
placeholder="Title (blank = default)"
disabled={!api}
onChange={(event) => api && actions.title(api, event.target.value)}
/>
<select
aria-label="Table start row"
disabled={!api}
onChange={(event) => api && actions.start(api, event.target.value)}
>
<option value="r1">Row 1 (overlap error)</option>
<option value="r3">Row 3</option>
<option value="r5">Row 5</option>
</select>
<button
type="button"
disabled={!api}
onClick={() => api && actions.download(api)}
>Download</button>
</div>
<Grid style={{ height: 300 }} ref={gridRef} options={options} />
</>
);
}import { withExport } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
export interface Row {
id: number;
region: string;
sales: number;
target: number;
}
const regions = ['New York', 'Chicago', 'Dallas', 'Denver', 'Seattle'];
const rows: Row[] = regions.map((region, i) => ({
id: i + 1,
region,
sales: (8200 + i * 1350) / 1000,
target: (9000 + i * 900) / 1000,
}));
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: 'Region', width: 100 },
{ id: 'sales', title: 'Sales ($K)', kind: 'number', width: 110, align: 'end' },
{ id: 'target', title: 'Target ($K)', kind: 'number', width: 110, align: 'end' },
],
rows,
rowKey: 'id',
};
let title = 'Sales by region';
let startRow = 3;
let say: (message: LogText) => void = () => {};
export const actions = {
title: (_api: GridApi<Row>, v?: string) => void (title = (v ?? '').trim() || 'Sales by region'),
start: (_api: GridApi<Row>, v?: string) => void (startRow = Number((v ?? 'r3').slice(1))),
download: async (api: GridApi<Row>) => {
const ex = withExport(api);
// The title and date are cells outside the table. A startRow below 3 overlaps the table and throws.
const o = {
startRow,
extraCells: [
{ ref: 'A1', value: title, style: { bold: true, color: '#1F4E79', fill: '#DDEBF7' } },
{ ref: 'A2', value: new Date(2026, 10, 25), style: { numFmt: 'yyyy-mm-dd' } },
],
};
try {
await ex.downloadXlsx('sales-title.xlsx', o);
say(`Downloaded. Title A1 · date A2 · table starts at row ${startRow}`);
} catch (e) {
say(`Could not download: ${(e as Error).message}`);
}
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
withExport(api);
log(
'A title and date go in rows 1 and 2 and the table starts at row 3. Set the start row to 1 to see the overlap error.',
);
} This example needs an extra package. To run it locally, install with npm i @maxgrid/vue @maxgrid/export.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<input
type="text"
aria-label="Title"
placeholder="Title (blank = default)"
:disabled="!api"
@input="api && actions.title(api, ($event.target as HTMLInputElement).value)"
/>
<select
aria-label="Table start row"
:disabled="!api"
@change="api && actions.start(api, ($event.target as HTMLSelectElement).value)"
>
<option value="r1">Row 1 (overlap error)</option>
<option value="r3" selected>Row 3</option>
<option value="r5">Row 5</option>
</select>
<button
type="button"
:disabled="!api"
@click="api && actions.download(api)"
>Download</button>
</div>
<Grid style="height: 300px" :options="options" @ready="onReady" />
</template>import { withExport } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
export interface Row {
id: number;
region: string;
sales: number;
target: number;
}
const regions = ['New York', 'Chicago', 'Dallas', 'Denver', 'Seattle'];
const rows: Row[] = regions.map((region, i) => ({
id: i + 1,
region,
sales: (8200 + i * 1350) / 1000,
target: (9000 + i * 900) / 1000,
}));
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: 'Region', width: 100 },
{ id: 'sales', title: 'Sales ($K)', kind: 'number', width: 110, align: 'end' },
{ id: 'target', title: 'Target ($K)', kind: 'number', width: 110, align: 'end' },
],
rows,
rowKey: 'id',
};
let title = 'Sales by region';
let startRow = 3;
let say: (message: LogText) => void = () => {};
export const actions = {
title: (_api: GridApi<Row>, v?: string) => void (title = (v ?? '').trim() || 'Sales by region'),
start: (_api: GridApi<Row>, v?: string) => void (startRow = Number((v ?? 'r3').slice(1))),
download: async (api: GridApi<Row>) => {
const ex = withExport(api);
// The title and date are cells outside the table. A startRow below 3 overlaps the table and throws.
const o = {
startRow,
extraCells: [
{ ref: 'A1', value: title, style: { bold: true, color: '#1F4E79', fill: '#DDEBF7' } },
{ ref: 'A2', value: new Date(2026, 10, 25), style: { numFmt: 'yyyy-mm-dd' } },
],
};
try {
await ex.downloadXlsx('sales-title.xlsx', o);
say(`Downloaded. Title A1 · date A2 · table starts at row ${startRow}`);
} catch (e) {
say(`Could not download: ${(e as Error).message}`);
}
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
withExport(api);
log(
'A title and date go in rows 1 and 2 and the table starts at row 3. Set the start row to 1 to see the overlap error.',
);
} This example needs an extra package. To run it locally, install with npm i @maxgrid/angular @maxgrid/export.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<input
type="text"
aria-label="Title"
placeholder="Title (blank = default)"
[disabled]="!api"
(input)="api && actions.title(api, $any($event.target).value)"
/>
<select
aria-label="Table start row"
[disabled]="!api"
(change)="api && actions.start(api, $any($event.target).value)"
>
<option value="r1">Row 1 (overlap error)</option>
<option value="r3" selected>Row 3</option>
<option value="r5">Row 5</option>
</select>
<button
type="button"
[disabled]="!api"
(click)="api && actions.download(api)"
>Download</button>
</div>
<mx-grid style="height: 300px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import { withExport } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string;
export interface Row {
id: number;
region: string;
sales: number;
target: number;
}
const regions = ['New York', 'Chicago', 'Dallas', 'Denver', 'Seattle'];
const rows: Row[] = regions.map((region, i) => ({
id: i + 1,
region,
sales: (8200 + i * 1350) / 1000,
target: (9000 + i * 900) / 1000,
}));
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: 'Region', width: 100 },
{ id: 'sales', title: 'Sales ($K)', kind: 'number', width: 110, align: 'end' },
{ id: 'target', title: 'Target ($K)', kind: 'number', width: 110, align: 'end' },
],
rows,
rowKey: 'id',
};
let title = 'Sales by region';
let startRow = 3;
let say: (message: LogText) => void = () => {};
export const actions = {
title: (_api: GridApi<Row>, v?: string) => void (title = (v ?? '').trim() || 'Sales by region'),
start: (_api: GridApi<Row>, v?: string) => void (startRow = Number((v ?? 'r3').slice(1))),
download: async (api: GridApi<Row>) => {
const ex = withExport(api);
// The title and date are cells outside the table. A startRow below 3 overlaps the table and throws.
const o = {
startRow,
extraCells: [
{ ref: 'A1', value: title, style: { bold: true, color: '#1F4E79', fill: '#DDEBF7' } },
{ ref: 'A2', value: new Date(2026, 10, 25), style: { numFmt: 'yyyy-mm-dd' } },
],
};
try {
await ex.downloadXlsx('sales-title.xlsx', o);
say(`Downloaded. Title A1 · date A2 · table starts at row ${startRow}`);
} catch (e) {
say(`Could not download: ${(e as Error).message}`);
}
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
withExport(api);
log(
'A title and date go in rows 1 and 2 and the table starts at row 3. Set the start row to 1 to see the overlap error.',
);
}