cycyexcel
中文0.2.0

API

CyExcelCore

The spreadsheet core provides rendering, interaction, and data APIs, with changes managed through Command, Mutation, and History.

Data

NameTypeDescription
getCell(row, column)unknownRead the underlying value of a cell.
getUsedRowCount()numberThe occupied row extent, excluding trailing blank rows.
getRowCount()numberThe coordinate-space row count, including trailing blank rows.
getColumnCount()numberThe coordinate-space column count, including trailing blank columns.
setCell(row, column, value)voidWrite an undoable cell value. null / undefined clears the value.
undo()voidUndo the most recent undoable change.
redo()voidRedo the most recently undone change.

Structure and geometry

NameTypeDescription
insertRows(start, count)voidInsert blank rows.
deleteRows(start, count)voidDelete consecutive rows.
moveRows(start, count, target)voidMove a block of rows to an insertion position.
insertColumns(start, columns)voidInsert column definitions.
deleteColumns(start, count)voidDelete consecutive columns.
moveColumns(start, count, target)voidMove columns.
setRowHeight(row, height)voidSet an explicit row height.
setColumnWidth(column, width)voidSet an explicit column width.

Styles

NameTypeDescription
setCellStyle(row, column, patch)voidApply a style patch to one cell.
setRangeStyle(range, patch)voidApply a style patch to a range, replacing only the specified keys.
getCellStyle(row, column)CellStyle | undefinedRead the merged column defaults and cell styles.
clearRangeStyle(range)voidClear explicit style keys within a range.

Search, sorting, and clipboard

NameTypeDescription
find(query, options)Promise<SearchMatch[] | null>Search displayed text and return matching cells.
findNext() / findPrevious()SearchMatch | nullNavigate through matches and select the corresponding cell.
replace(match, value, query?, options?)voidReplace matched text. Without query, the method retains the legacy whole-cell write behavior.
replaceAll(query, value, options?)Promise<number | null>Replace all matches and return the number of replacements.
sortByColumn(column, direction)booleanSort rows by a column, committing the order and row geometry in one transaction.
filterByColumn(column, predicate)voidFilter rows using a predicate. Filtered-out rows have zero height.
copy(options?) / paste(options?)PromiseCopy and paste programmatically.

Data validation

Validation rules are stored by range in snapshots. Changes are undoable, and ranges update with row and column insertion, deletion, and movement. See Examples > Data validation.

NameTypeDescription
setDataValidation(range | ranges, rule)stringSet a rule on one or more ranges and return its ID. Each cell belongs to at most one rule; new coverage is removed from older rules. Existing values are not checked.
clearDataValidation(range | ranges)voidClear rule coverage in these ranges and remove rules with no remaining coverage. Undoable.
getDataValidations()readonly DataValidationRule[]All current rules.
getDataValidationAt(row, column)DataValidationRule | undefinedReturn the rule covering the specified cell.
validateCell(row, column)DataValidationResultCheck the specified cell against its rule. Cells without a rule are valid.
findInvalidCells(range?){ row, column }[]Return coordinates of invalid cells. Without a range, check the entire coordinate space.
registerDataValidator(name, fn)DisposerRegister a synchronous pure validator returning true, false, or an error message. Validators are instance-specific and are not serialized.