
{ sheetName, row, col, rowCount, colCount } data and re-resolved to pixels with SpreadJS cell geometry whenever comments render.
Setup
Step 1: Add Comment components
- Add the
Velt Commentscomponent to the root of your app. This component is required to create and render comments in your app. - Authenticate the user with
authProviderand set the Velt document before users add comments. - Set the
textModeprop tofalseto hide the default Velt text comment tool. SpreadJS selections are handled by@veltdev/spreadjs-velt-comments. - Add
VeltCommentsSidebarif you want a Google Docs-style comment sidebar.
- React / Next.js
Step 2: Install the Velt SpreadJS extension
@mescius/spread-sheets is a peer dependency of the Velt SpreadJS package. @mescius/spread-sheets-io is required when you import XLSX files into a workbook.
- React / Next.js
Step 3: Configure the SpreadJS workbook with the Velt Comments extension
Create the workbook, import your spreadsheet, then attachSpreadJSVeltComments after the import completes. The same workbook instance is used by addComment and renderComments.
- React / Next.js
Step 4: Add a comment button to your SpreadJS workbook
SpreadJS renders the grid to a canvas, so there is no DOM text selection for a default text bubble menu. Add a toolbar button or contextual selection bubble that uses the workbook’s selected cell/range state, then calladdComment({ instance }).
- React / Next.js
Step 5: Call addComment to add a comment
- Call this method to add a comment to the currently selected cell or range.
- Params:
AddCommentArgs. It has the following properties:instance: SpreadJS workbook instance created withnew GC.Spread.Sheets.Workbook(host).
- Returns:
Promise<AddCommentResult | null>. It returnsnullif no cell/range is selected or Velt is not loaded.
- React / Next.js
Step 6: Render comments in SpreadJS workbook
- Get comment data from the Velt SDK and render it in the SpreadJS workbook.
- Params:
RenderCommentsArgs. It has the following properties:instance: SpreadJS workbook instance.commentAnnotations: Array of Comment Annotation objects.
- React / Next.js
TextEditorConfig anchor and SpreadJS repositions the overlays across scroll, zoom, row/column resize, and sheet changes. Re-run renderComments when Velt’s annotation list changes or when you import a new workbook.
Step 7: Clean up the Velt SpreadJS extension
SpreadJSVeltComments.configure(...).attach(instance) returns an AttachedExtension. Call detach() in your effect cleanup to remove listeners, clear per-instance state, and remove overlay elements before destroying the workbook.
Step 8: Style the commented text
- Each comment is rendered through a
.velt-spreadjs-overlaylayer with a.velt-spreadjs-highlightrange fill and avelt-comment-textmarker. - Override the default inline highlight styles with
!important.
Complete Example
APIs
SpreadJSVeltComments
Creates the Velt Comments extension for a SpreadJS workbook. UseSpreadJSVeltComments.configure(...).attach(instance) to attach it to a workbook instance.
- Config:
SpreadJSVeltCommentsConfig - Returns:
SpreadJSVeltComments
- React / Next.js
addComment()
Creates a comment annotation for the currently selected SpreadJS cell or range.- Signature:
async (args: AddCommentArgs) => Promise<AddCommentResult | null> - Params:
args:AddCommentArgs - Returns:
Promise<AddCommentResult | null>; seeAddCommentResult.
- React / Next.js
renderComments()
Renders and updates Velt comment highlights in the SpreadJS workbook.- Signature:
(args:RenderCommentsArgs) => void - Params:
args:RenderCommentsArgs - Returns:
void
- React / Next.js

