Class: Cell

Core.SpreadsheetEditor. Cell

Represents a cell in the spreadsheet editor. A cell is the fundamental component in spreadsheet document manipulation, providing a range of methods and properties to manage the content and appearance of individual cells.

new Cell()

Properties:
Name Type Description
cellType Core.SpreadsheetEditor.Types.CellType The type of the cell, which can be one of the predefined cell types such as string, numeric, boolean, date, or formula.
columnIndex string The index of the column that the cell belongs to, represented as a string.
rowIndex string The index of the row that the cell belongs to, represented as a string.
stringCellValue string The string value of the cell, if it is a string type cell.
boolCellValue boolean The boolean value of the cell, if it is a boolean type cell.
dateCellValue Date The date value of the cell, if it is a date type cell.
numericCellValue number The numeric value of the cell, if it is a numeric type cell.
cellFormula string The formula string of the cell, if it is a formula type cell.
hyperlink string The hyperlink associated with the cell, if any.
isMerged boolean Indicates whether the cell is part of a merged cell range.

Methods


getDisplayStringValue()

Gets the text representation of a cell value, including any formatting that has been applied to the cell.
Returns:
A string representation of the cell value.
Type
string

getStyle()

Retrieves the CellStyle object that encapsulates various styling details, such as font and border settings of a cell.
Returns:
An object representing the style settings of the cell, which includes information about font, border, and other formatting aspects.
Type
Core.SpreadsheetEditor.CellStyle

setBooleanValue(value)

Sets the value of the cell to the provided boolean value.
Parameters:
Name Type Description
value boolean The boolean value to set in the cell.

setDateValue(date)

Sets the value of the cell to the provided date time string. If the date string is valid and falls after 1900-01-00 00:00:00, it will be converted and set as a date-type cell value. Otherwise, the date is formatted as a string value in the format "yyyy-MM-dd hh:mm:ss" in the cell. If you want to apply a different date format to the cell, you can use Core.SpreadsheetEditor.CellStyle#setDataFormatString with Core.SpreadsheetEditor.Cell#setStyle to apply the new format.
Parameters:
Name Type Description
date string A string representing a date in the format "yyyy-MM-dd hh:mm:ss"
See:
Example
const { Core } = window.getInstance();
const { documentViewer, SpreadsheetEditor } = Core;
const spreadsheetEvents = SpreadsheetEditor.SpreadsheetEditorManager.Events;
const spreadsheetEditorManager = documentViewer.getSpreadsheetEditorManager();

const datetimeString = '2023-10-01 06:00:00';
const spreadsheetEditorDocument = Core.documentViewer.getDocument().getSpreadsheetEditorDocument();
const cell = spreadsheetEditorDocument.getWorkbook().getSheetAt(0).getRowAt(0).getCellAt(0);
cell.setDateValue(datetimeString);

// To apply a different date format to the cell
const cellStyle = cell.getStyle();
cellStyle.setDataFormatString('MM/dd/yyyy');
cell.setStyle(cellStyle);

setFormula(value)

Sets a formula for the cell. The formula will be evaluated and the result will be displayed in the cell.
Parameters:
Name Type Description
value string The formula string to set in the cell (e.g., "=SUM(A1:B1)").

setNumericValue(value)

Sets the value of the cell to the provided numeric value.
Parameters:
Name Type Description
value number The numeric value to set in the cell.

setStringValue(value)

Sets the value of the cell to the provided string.
Parameters:
Name Type Description
value string The string value to set in the cell.

setStyle(cellStyle)

Applies a specific style as defined by a CellStyle object to a cell within a sheet. Thus, enabling the customization of cell appearance, including aspects like font, alignment, and border settings.
Parameters:
Name Type Description
cellStyle Core.SpreadsheetEditor.CellStyle The object that encapsulates the styling properties to be applied to the cell.