-
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 datetime 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
WebViewer.Iframe(...)
.then(instance => {
const { documentViewer, SpreadsheetEditor } = instance.Core;
const SpreadsheetEditorEvents = SpreadsheetEditor.SpreadsheetEditorManager.Events;
const spreadsheetEditorManager = documentViewer.getSpreadsheetEditorManager();
spreadsheetEditorManager.addEventListener(SpreadsheetEditorEvents.SPREADSHEET_EDITOR_READY, async () => {
await spreadsheetEditorManager.setEditMode(SpreadsheetEditor.SpreadsheetEditorEditMode.EDITING);
const spreadsheetEditorDocument = documentViewer.getDocument().getSpreadsheetEditorDocument();
const workbook = spreadsheetEditorDocument.getWorkbook();
const cell = workbook
.getSheetAt(0)
.getRowAt(0)
.getCellAt(0);
const datetimeString = '2023-10-01 06:00:00';
cell.setDateValue(datetimeString);
// Alternatively you can apply a different date format to the cell:
// const cellStyle = cell.getStyle();
// cellStyle.setDataFormatString('MM/dd/yyyy');
// cell.setStyle(cellStyle);
});
});
-
-
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 styling to a cell within a sheet. Styling includes font, text alignment, background color, and more.
Parameters:
Example
WebViewer.Iframe(...)
.then(instance => {
const { documentViewer, SpreadsheetEditor } = instance.Core;
const SpreadsheetEditorEvents = SpreadsheetEditor.SpreadsheetEditorManager.Events;
const spreadsheetEditorManager = documentViewer.getSpreadsheetEditorManager();
spreadsheetEditorManager.addEventListener(SpreadsheetEditorEvents.SPREADSHEET_EDITOR_READY, async () => {
await spreadsheetEditorManager.setEditMode(SpreadsheetEditor.SpreadsheetEditorEditMode.EDITING);
const spreadsheetEditorDocument = documentViewer.getDocument().getSpreadsheetEditorDocument();
const workbook = spreadsheetEditorDocument.getWorkbook();
const cell = workbook
.getSheetAt(0)
.getRowAt(0)
.getCellAt(0);
const font = workbook.createFont({
fontFace: 'Times New Roman',
pointSize: 12,
color: 'red',
bold: true,
italic: true,
underline: true
});
const cellStyle = cell.getStyle();
cellStyle.font = font;
cellStyle.horizontalAlignment = SpreadsheetEditor.Types.HorizontalAlignment.CENTER;
cellStyle.verticalAlignment = SpreadsheetEditor.Types.VerticalAlignment.CENTER;
cellStyle.backgroundColor = 'lightgreen';
cellStyle.wrapText = SpreadsheetEditor.Types.TextWrap.OVERFLOW;
cell.setStyle(cellStyle);
});
});