### Install SheetNext via npm Source: https://github.com/wyyazlz/sheetnext/blob/master/README.md Install the SheetNext package using npm. This is the first step for traditional integration. ```bash npm install sheetnext ``` -------------------------------- ### SSE Stream Example Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/ai-relay.md Example of the SSE stream format. Each event is a data: line followed by a blank line. The stream ends with data: [DONE]. ```text data: {"type":"text","delta":"Hello"} data: {"type":"text","delta":" world"} data: [DONE] ``` -------------------------------- ### buildSegments(start, end, sizeGetter, maxSize, forcedStarts = []) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Builds an array of page segments based on the start and end indices, using a size getter function and maximum size constraint. ```APIDOC ## buildSegments(start, end, sizeGetter, maxSize, forcedStarts = []) ### Description Builds an array of page segments based on the start and end indices, using a size getter function and maximum size constraint. ### Method buildSegments ### Parameters - **start** (number) - Required - Initial Index - **end** (number) - Required - End Index - **sizeGetter** (Function) - Required - Fetch Size Method - **maxSize** (number) - Required - Maximum size - **forcedStarts** (Array) - Optional - Default: [] ### Returns - Type: `Array<{s: number, e: number}>` ``` -------------------------------- ### startRangePicker(options = {}): () => void Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/canvas.md Starts a modeless grid range-picking session. Returns a disposer function. ```APIDOC ## startRangePicker(options = {}): () => void ### Description Start a modeless grid range-picking session. ### Parameters | Name | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | options | Object | No | {} | Picker callbacks and target context | | options.onChange | (reference:string, detail:{area:Object, sheet:Object})=>void | Yes | - | Range change callback | | options.targetSheetName | string | No | - | Formula target sheet used to qualify cross-sheet references | ### Returns - Type: `() => void` - Session disposer ``` -------------------------------- ### getSettings Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Gets print settings for a sheet as a deep copy. ```APIDOC ## getSettings(sheet) ### Description Gets print settings for a sheet as a deep copy. ### Method getSettings(sheet) ### Parameters - **sheet** (Sheet) - Optional - Default: `this.SN.activeSheet` - The sheet to get settings for. ### Returns - Type: `Object | null` - The print settings object, or null if not available. ``` -------------------------------- ### getCol example Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/sheet.md Retrieves a column by index and sets its width and hidden state. ```javascript const col = SN.activeSheet.getCol(1); col.width = 120; col.hidden = false; ``` -------------------------------- ### getRow example Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/sheet.md Retrieves a row by index and sets its height and hidden state. ```javascript const row = SN.activeSheet.getRow(0); row.height = 32; row.hidden = false; ``` -------------------------------- ### Recommended prompt template for AI coding assistants Source: https://github.com/wyyazlz/sheetnext/blob/master/README.md A prompt template to guide AI tools like Cursor, Claude, ChatGPT, or Copilot. It instructs the AI to read the provided reference documentation and produce a minimum viable implementation, with constraints against fabricating APIs and skipping edge cases. ```text You are a senior SheetNext AI development expert. Please read and understand the documentation I provide, then give a directly implementable solution. Execution order: 1) Read: docs/skill/sheetnext-dev/references/core-api.md 2) Read as needed: docs/skill/sheetnext-dev/references/events.md, docs/skill/sheetnext-dev/references/enums.md, docs/skill/sheetnext-dev/references/ai-relay.md, and docs/skill/sheetnext-dev/references/json-format.md 3) Identify user goals (business goals + technical goals) 4) Output a minimum viable implementation (get it running first, then optimize) 5) All APIs and code must strictly follow the documentation 6) Provide verification steps and risk points Constraints: - Do not fabricate APIs - Do not skip edge cases - Prioritize reusing existing capabilities, avoid over-engineering ``` -------------------------------- ### Install SheetNext Dev skill to Codex skills directory Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/adapters/codex.md Run from the SNEditor directory to copy the skill into the user's Codex skills folder. Restart Codex after copying. ```powershell Copy-Item -Recurse -Force .\docs\skill\sheetnext-dev "$env:USERPROFILE\.codex\skills\sheetnext-dev" ``` -------------------------------- ### ensureSettings Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Gets and ensures print settings for a sheet, creating them if necessary. ```APIDOC ## ensureSettings(sheet) ### Description Gets and ensures print settings for a sheet, creating them if necessary. ### Method ensureSettings(sheet) ### Parameters - **sheet** (Sheet) - Optional - Default: `this.SN.activeSheet` - The sheet to ensure settings for. ### Returns - Type: `Object | null` - The print settings object, or null if not available. ``` -------------------------------- ### eachCells example Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/sheet.md Iterates over cells in a range and applies a fill color to each cell. ```javascript SN.activeSheet.eachCells('A1:C3', (rowIndex, colIndex) => { const cell = SN.activeSheet.getCell(rowIndex, colIndex); cell.fill = { fgColor: '#FFF4CC' }; }); ``` -------------------------------- ### CF.getDxfList() Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/cf.md Gets the dxf style list for exporting styles.xml. ```APIDOC ## CF.getDxfList() ### Description Gets the dxf style list for exporting styles.xml. ### Method getDxfList ### Returns - **Array** - Dxf style list ``` -------------------------------- ### Add a table with options Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/table.md Creates a new table using the `add` method on the active sheet's Table object. The example sets the range, name, and display options for the table. ```javascript const table = SN.activeSheet.Table; table.add({ rangeRef: 'A1:D10', name: 'Sales', showHeaderRow: true, showRowStripes: true }); ``` -------------------------------- ### async conversation(p, joinChat = true): Promise Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/ai.md Starts or continues a conversation with the AI assistant. Optionally joins the chat if joinChat is true. ```APIDOC ## async conversation(p, joinChat = true): Promise ### Description Starts or continues a conversation with the AI assistant. Optionally joins the chat if joinChat is true. ### Method conversation ### Parameters - **p** (string) - Required - The prompt or message for the conversation. - **joinChat** (boolean) - Optional, default: true - Whether to join the chat. ### Returns - **Promise** - Resolves when the conversation completes. ``` -------------------------------- ### Add and configure a pivot table with PivotTable.add Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/pivottable.md Shows how to create a pivot table from a worksheet range, add row, column, and data fields, set a sort, and refresh. The example uses the active sheet and a source range 'A1:D100', placing the pivot table at cell 'F1' with name 'SalesPivot'. Field indices are 0-based source column indices. ```javascript const sheet = SN.activeSheet; const pt = sheet.PivotTable.add({ sourceSheet: sheet, sourceRangeRef: 'A1:D100', cellRef: 'F1', name: 'SalesPivot' }); // fieldIndex is the 0-based source column index. pt.addRowField(0); pt.addColField(1); pt.addDataField(3, 'sum'); pt.setFieldSort(0, 'asc'); pt.refresh(); ``` -------------------------------- ### getCell example Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/sheet.md Retrieves a cell by reference and sets its edit value and number format. ```javascript const totalCell = SN.activeSheet.getCell('B2'); totalCell.editVal = 2560; totalCell.numFmt = '#,##0.00'; ``` -------------------------------- ### Minimal Workbook Example JSON Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/json-format.md A minimal complete SheetNext workbook JSON with version, workbookName, activeSheet, calcMode, readOnly, properties, definedNames, styleTable, sizeTable, and sheets. The sheet includes rows with cells, merges, and drawings. ```json { "version": "2.0", "workbookName": "Demo", "activeSheet": "Sheet1", "calcMode": "auto", "readOnly": false, "properties": {}, "definedNames": {}, "styleTable": { "fonts": [], "fills": [], "borders": [], "aligns": [], "styles": [] }, "sizeTable": { "rowHeights": [], "colWidths": [] }, "sheets": [ { "name": "Sheet1", "hidden": false, "showGridLines": true, "showRowColHeaders": true, "showPageBreaks": false, "outlinePr": {}, "frozenCols": 0, "frozenRows": 0, "freezeStartRow": 0, "freezeStartCol": 0, "defaultColWidth": 72, "defaultRowHeight": 21, "zoom": 1, "activeCell": { "r": 0, "c": 0 }, "viewStart": { "r": 0, "c": 0 }, "printSettings": null, "rowCount": 10, "colCount": 10, "cols": [], "rows": [ { "rIndex": 0, "cells": [ { "c": 0, "v": "Name" }, { "c": 1, "v": "Score" } ] }, { "rIndex": 1, "cells": [ { "c": 0, "v": "Alice" }, { "c": 1, "v": 95 } ] } ], "merges": [], "drawings": [] } ] } ``` -------------------------------- ### rangeStrToNum example Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/sheet.md Converts a range string like 'A1:C3' to a RangeNum object and logs its start and end coordinates. ```javascript const sheet = SN.activeSheet; const range = sheet.rangeStrToNum('A1:C3'); console.log(range.s, range.e); ``` -------------------------------- ### preview(options) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Opens the print settings and preview panel. ```APIDOC ## preview(options) ### Description Open the print settings and preview panel. ### Method preview ### Parameters - **options** (Object) - Optional - Default: {} - Preview Options ### Returns Promise ``` -------------------------------- ### initColorComponents(scope?) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/layout.md Initializes color components. ```APIDOC ## initColorComponents(scope?) ### Description Initializes color components. ### Method initColorComponents ### Parameters - **scope** (Element) - Optional - Optional scope. ### Returns void ``` -------------------------------- ### applyZoom(): void Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/canvas.md Applies zoom and synchronizes scrollbar and input box positions. ```APIDOC ## applyZoom(): void ### Description Apply zoom and synchronize scrollbar and input box positions. ``` -------------------------------- ### PivotTable.getAll() Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/pivottable.md Gets all pivot tables. ```APIDOC ## PivotTable.getAll() ### Description Gets all pivot tables. ### Method getAll ### Parameters None ### Returns - Type: `Array` ``` -------------------------------- ### setHighlight(event): void Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/canvas.md Sets highlight color and syncs toolbar status. ```APIDOC ## setHighlight(event): void ### Description Set highlight color and sync toolbar status. ### Parameters | Name | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | event | MouseEvent | Yes | - | Trigger event | ``` -------------------------------- ### getTotalWidth(): number Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/sheet.md Gets the total width of all columns. ```APIDOC ## getTotalWidth(): number ### Description Get the total width of all columns. ### Method Function ### Signature `getTotalWidth()` ### Returns - Type: `number` ### Source `src/core/Sheet/ViewCalculator.js` | Category: `ViewCalculator` ``` -------------------------------- ### PivotTable.get(name) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/pivottable.md Gets a pivot table by name. ```APIDOC ## PivotTable.get(name) ### Description Gets a pivot table by name. ### Method get ### Parameters - **name** (string) - Required - Pivot table name ### Returns - Type: `PivotTable | null` ``` -------------------------------- ### initResizeObserver() Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/layout.md Initializes the ResizeObserver for handling resize events. ```APIDOC ## initResizeObserver() ### Description Initializes the ResizeObserver for handling resize events. ### Method initResizeObserver ### Parameters None ### Returns void ``` -------------------------------- ### getPrintRange(sheet, settings) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Gets the actual print range. ```APIDOC ## getPrintRange(sheet, settings) ### Description Get Actual Print Range. ### Method getPrintRange ### Parameters - **sheet** (Sheet) - Required - Sheet - **settings** (Object) - Required - Print Settings ### Returns {s: {r: number, c: number}, e: {r: number, c: number}} | null ``` -------------------------------- ### handleAllResize() Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/layout.md Handles all resize-related logic. ```APIDOC ## handleAllResize() ### Description Handles all resize-related logic. ### Method handleAllResize ### Parameters None ### Returns void ``` -------------------------------- ### Generate license report with license-checker Source: https://github.com/wyyazlz/sheetnext/blob/master/THIRD_PARTY_LICENSES.md Run this command in your environment to produce a summary of third-party licenses. The output should be tracked and archived for release compliance. ```bash npx license-checker --production --summary ``` -------------------------------- ### CF.getDxfId(dxf) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/cf.md Gets the dxf style index for export. ```APIDOC ## CF.getDxfId(dxf) ### Description Gets the dxf style index for export. ### Method getDxfId ### Parameters - **dxf** (Object) - Required - Differentiated Style Objects ### Returns - **number** - dxfId ``` -------------------------------- ### getSortOrder(colIndex, scopeId = null) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/autofilter.md Gets sorting status. ```APIDOC ## getSortOrder(colIndex, scopeId = null) ### Description Gets sorting status. ### Method getSortOrder ### Parameters - **colIndex** (number) - Required - Column index. - **scopeId** (string) - Optional - Scope identifier, defaults to null. ``` -------------------------------- ### initEventListeners() Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/layout.md Initializes all event listeners. ```APIDOC ## initEventListeners() ### Description Initializes all event listeners. ### Method initEventListeners ### Parameters None ### Returns void ``` -------------------------------- ### delRows(r, number) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/sheet.md Deletes rows starting at the specified index. ```APIDOC ## delRows(r, number) ### Description Delete Row. ### Method delRows ### Signature `delRows(r, number = 1)` ### Parameters - **r** (number) - Required - Remove Row Index at Start Location. - **number** (number) - Optional (default: 1) - Number of rows deleted. ``` -------------------------------- ### Workbook Get Accessors Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/workbook.md Documents the getter accessor for the current locale. ```APIDOC ## Workbook Get Accessors ### Description Documents the getter accessor for the current locale. ### Accessors - **locale** (string) - get - The current locale string. ``` -------------------------------- ### UndoRedo.begin(name = ''): void Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/undoredo.md Begins a manual undo transaction with an optional name. ```APIDOC ## UndoRedo.begin(name = ''): void ### Description Begins a manual undo transaction. ### Method begin ### Parameters - **name** (string) - Optional - Default: '' - The name of the transaction. ### Returns void ``` -------------------------------- ### Slicer.getAll(): Array Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/slicer.md Gets all slicers managed by the Slicer manager. ```APIDOC ## Slicer.getAll(): Array ### Description Gets all slicers managed by the Slicer manager. ### Method getAll ### Returns - Type: `Array` ``` -------------------------------- ### Basic Workbook initialization with SheetNext Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/workbook.md Creates a new SheetNext workbook instance by importing the library and CSS, then instantiating with a container element. The container is selected via a CSS class. ```javascript import SheetNext from 'sheetnext'; import 'sheetnext/dist/sheetnext.css'; const container = document.querySelector('.sheetnext-container'); const SN = new SheetNext(container); ``` -------------------------------- ### getScrollLeft(colIndex): number Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/sheet.md Gets the sum of widths before the specified column. ```APIDOC ## getScrollLeft(colIndex): number ### Description Sum of widths before the specified column. ### Method Function ### Signature `getScrollLeft(colIndex)` ### Parameters - **colIndex** (number) - Required - Column index ### Returns - Type: `number` ### Source `src/core/Sheet/ViewCalculator.js` | Category: `ViewCalculator` ``` -------------------------------- ### getScrollTop(rowIndex): number Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/sheet.md Gets the sum of heights before the specified row. ```APIDOC ## getScrollTop(rowIndex): number ### Description Get the sum of heights before the specified row. ### Method Function ### Signature `getScrollTop(rowIndex)` ### Parameters - **rowIndex** (number) - Required - Row index ### Returns - Type: `number` ### Source `src/core/Sheet/ViewCalculator.js` | Category: `ViewCalculator` ``` -------------------------------- ### initSheetPrintSettings Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Initializes printing settings for a sheet. ```APIDOC ## initSheetPrintSettings(sheet) ### Description Initializes printing settings for a sheet. ### Method initSheetPrintSettings(sheet) ### Parameters - **sheet** (Sheet) - Required - The sheet to initialize settings for. ### Returns - Type: `Object` - The initialized print settings object. ``` -------------------------------- ### Initialize SheetNext with npm import Source: https://github.com/wyyazlz/sheetnext/blob/master/README.md Import SheetNext and its CSS, then create a new instance by passing the container element. This is the core initialization code for npm-based integration. ```javascript import SheetNext from 'sheetnext'; import 'sheetnext.css'; const SN = new SheetNext(document.querySelector('#SNContainer')); ``` -------------------------------- ### toggleShowPageBreaks(on, sheet) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Shows or hides the page break guide in the UI. ```APIDOC ## toggleShowPageBreaks(on, sheet) ### Description Show/Hide Page Break Guide. ### Method toggleShowPageBreaks ### Parameters - **on** (boolean) - Required - Whether to show - **sheet** (Sheet) - Optional - Default: this.SN.activeSheet - Sheet ### Returns void ``` -------------------------------- ### prepareForExport() Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/pivottable.md Prepares the pivot table for export. ```APIDOC ## prepareForExport() ### Description Prepares the pivot table for export. ### Method prepareForExport ### Parameters None ### Returns None ``` -------------------------------- ### async renderPage(page, options = {}) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Renders a single job page, including repeated titles. Accepts an optional cancellation signal. ```APIDOC ## async renderPage(page, options = {}) ### Description Renders a single job page, including repeated titles. Accepts an optional cancellation signal. ### Method renderPage ### Parameters - **page** (Object) - Required - A page descriptor from createJob. - **options** ({signal?: AbortSignal}) - Optional - Default: {} - Optional cancellation signal. ### Returns - Type: `Promise` ``` -------------------------------- ### print(options) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Prints a job through the browser's system print dialog. ```APIDOC ## print(options) ### Description Print a job through the browser's system print dialog. ### Method print ### Parameters - **options** (Object) - Optional - Default: {} - Job options, or {job, fromPage, toPage, signal, onProgress}. ### Returns Promise ``` -------------------------------- ### cache (get/set) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/pivottable.md Gets or sets the cache object associated with the pivot table. ```APIDOC ## cache (get/set) ### Description Gets or sets the cache object associated with the pivot table. ### Property - **cache** (Object | null) - The cache object or null. ``` -------------------------------- ### async renderPages(sheet, settings, layout) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Renders all pages for the given sheet, settings, and layout information. ```APIDOC ## async renderPages(sheet, settings, layout) ### Description Renders all pages for the given sheet, settings, and layout information. ### Method renderPages ### Parameters - **sheet** (Sheet) - Required - Sheet - **settings** (Object) - Required - Print Settings - **layout** (Object) - Required - Layout Information ### Returns - Type: `Promise>` ``` -------------------------------- ### PivotTable.getByCell(row, col) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/pivottable.md Gets the pivot table containing a specific cell. ```APIDOC ## PivotTable.getByCell(row, col) ### Description Gets the pivot table containing a specific cell. ### Method getByCell ### Parameters - **row** (number) - Required - Row index - **col** (number) - Required - Column index ### Returns - Type: `PivotTableItem | null` ``` -------------------------------- ### getPageBreakGuides(sheet) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Retrieves page break guide information for canvas display. ```APIDOC ## getPageBreakGuides(sheet) ### Description Get page break guide information (for canvas display). ### Method getPageBreakGuides ### Parameters - **sheet** (Sheet) - Optional - Default: this.SN.activeSheet - Sheet ### Returns {range: Object, rowBreaks: Array<{index: number, manual: boolean}>, colBreaks: Array<{index: number, manual: boolean}>} | null ``` -------------------------------- ### async screenshot(addresses = []) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/ai.md Takes a screenshot of the specified addresses. If no addresses are provided, defaults to an empty array. ```APIDOC ## async screenshot(addresses = []) ### Description Takes a screenshot of the specified addresses. If no addresses are provided, defaults to an empty array. ### Method screenshot ### Parameters - **addresses** (Array) - Optional, default: [] - The addresses to capture in the screenshot. ``` -------------------------------- ### buildLayout(sheet, settings) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Builds page break layout information. ```APIDOC ## buildLayout(sheet, settings) ### Description Build page break layout information. ### Method buildLayout ### Parameters - **sheet** (Sheet) - Required - Sheet - **settings** (Object) - Required - Print Settings ### Returns Object ``` -------------------------------- ### Get a sheet with getSheet Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/workbook.md Retrieves a sheet by name and sets a cell value if the sheet exists. ```javascript const sheet = SN.getSheet('Budget 2026'); if (sheet) { sheet.getCell('B2').editVal = 128000; } ``` -------------------------------- ### getRowToggleInfo(row, col): Object | null Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/pivottable.md Gets toggle information for a cell in the pivot table. ```APIDOC ## getRowToggleInfo(row, col): Object | null ### Description Gets toggle information for a cell in the pivot table. ### Method getRowToggleInfo ### Parameters - **row** (number) - Required - Row index. - **col** (number) - Required - Column index. ### Returns - Type: `Object | null` ``` -------------------------------- ### getColumnValues(colIndex, scopeId = null) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/autofilter.md Gets all unique values for a column, used for filter panel. ```APIDOC ## getColumnValues(colIndex, scopeId = null) ### Description Gets all unique values for a column, used for filter panel. ### Method getColumnValues ### Parameters - **colIndex** (number) - Required - Column index. - **scopeId** (string) - Optional - Scope identifier, defaults to null. ### Returns - Type: `Array<{value: any, text: string, count: number, isEmpty: boolean}>` ``` -------------------------------- ### Initialize Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/recipes.md Initializes a SheetNext instance with a locale and attaches it to a container element. ```APIDOC ## Initialize ### Description Initializes a SheetNext instance with a locale and attaches it to a container element. ### Method Constructor ### Endpoint `new SheetNext(container, options)` ### Parameters - **container** (HTMLElement) - Required - The DOM element to mount the spreadsheet. - **options** (Object) - Optional - Configuration options, e.g., `{ locale: 'zh-CN' }`. ### Request Example ```js import SheetNext from 'sheetnext'; import 'sheetnext/dist/sheetnext.css'; import zhCN from 'sheetnext/locales/zh-CN'; SheetNext.registerLocale('zh-CN', zhCN); const container = document.querySelector('.sheetnext-container'); const SN = new SheetNext(container, { locale: 'zh-CN' }); ``` ### Response No response value. The instance is created and ready for use. ``` -------------------------------- ### getEventPosition(event): {x: number, y: number} Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/canvas.md Gets the position of the event in the canvas (logical coordinates). ```APIDOC ## getEventPosition(event): {x: number, y: number} ### Description Gets the position of the event in the canvas (logical coordinates). ### Parameters | Name | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | event | MouseEvent \| {clientX: number, clientY: number} | Yes | - | Mouse event or object with coordinates | ### Returns - Type: `{x: number, y: number}` ``` -------------------------------- ### delCols(c, number = 1) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/sheet.md Deletes a specified number of columns starting from a given column index. ```APIDOC ## delCols(c, number = 1) ### Description Delete Column ### Method Function ### Signature `delCols(c, number = 1)` ### Parameters - **c** (number) - Required - Delete column index for starting position - **number** (number) - Optional, default: 1 - NUMBER OF ROWS REMOVED ### Source `src/core/Sheet/RowColHandler.js` | Category: `RowColHandler` ``` -------------------------------- ### createJob(options) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Creates a pagination snapshot without rendering images or changing saved print areas. ```APIDOC ## createJob(options) ### Description Create a pagination snapshot without rendering images or changing saved print areas. ### Method createJob ### Parameters - **options** (Object) - Optional - Default: {} - {sheet, scope: 'sheet'|'selection'|'workbook', ranges, ignorePrintArea}. ### Returns {pages: Array} ``` -------------------------------- ### getUsedRange(sheet) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Returns the used range of the sheet as a structured object with start and end cell coordinates. ```APIDOC ## getUsedRange(sheet) ### Description Returns the used range of the sheet as a structured object with start and end cell coordinates. ### Method getUsedRange ### Parameters - **sheet** (Sheet) - Required - Sheet ### Returns - Type: `{s: {r: number, c: number}, e: {r: number, c: number}}` ``` -------------------------------- ### rAllBtn() Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/canvas.md Renders all buttons in the index renderer. ```APIDOC ## rAllBtn() ### Description Renders all buttons. ### Parameters None ``` -------------------------------- ### buildPageHtml(page) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/print.md Generates the HTML for a single rendered page, used for both preview and print. ```APIDOC ## buildPageHtml(page) ### Description Generates the HTML for a single rendered page, used for both preview and print. ### Method buildPageHtml ### Parameters - **page** (Object) - Required - Rendered job page. ### Returns - Type: `string` - Paper HTML shared by preview and print. ``` -------------------------------- ### Slicer.get(id): Slicer | null Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/slicer.md Gets a slicer by its id. Returns the Slicer instance or null if not found. ```APIDOC ## Slicer.get(id): Slicer | null ### Description Gets a slicer by its id. ### Method get ### Parameters - **id** (string) - Required - The id of the slicer to retrieve. ### Returns - Type: `Slicer | null` ``` -------------------------------- ### CF.getFormat(r, c) Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/api/cf.md Gets a cell's conditional formatting. Returns a formatted object or null. ```APIDOC ## CF.getFormat(r, c) ### Description Gets a cell's conditional formatting. Returns a formatted object or null. ### Method getFormat ### Parameters - **r** (number) - Required - Row index - **c** (number) - Required - Column Index ### Returns - **Object | null** - formatted object ``` -------------------------------- ### Initialize SheetNext with locale Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/integration.md Imports SheetNext, its CSS, and a locale, registers the locale, and creates a new SheetNext instance on a container element. Requires a mounted container with explicit width and height. The locale subpath is 'sheetnext/locales/zh-CN' without '.js'. Use only in the browser after mounting, especially with SSR frameworks. ```javascript import SheetNext from 'sheetnext'; import 'sheetnext/dist/sheetnext.css'; import zhCN from 'sheetnext/locales/zh-CN'; SheetNext.registerLocale('zh-CN', zhCN); const container = document.querySelector('.sheetnext-container'); const SN = new SheetNext(container, { locale: 'zh-CN' }); ``` -------------------------------- ### Merge Record JSON Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/json-format.md Each merge item is a normalized range object with start (s) and end (e) cell coordinates. ```json { "s": { "r": 0, "c": 0 }, "e": { "r": 1, "c": 2 } } ``` -------------------------------- ### Recommended SSE Response Header Source: https://github.com/wyyazlz/sheetnext/blob/master/docs/skill/sheetnext-dev/references/ai-relay.md The client expects a streaming response parsed as SSE-style data: lines. Use this header to indicate the event-stream content type. ```text Content-Type: text/event-stream ```