-
addImage(src [, rect])
-
Adds an image to the sheet.
Parameters:
| Name |
Type |
Argument |
Description |
src |
string
|
|
The source path or Base64-encoded string of the image. |
rect |
object
|
<optional>
|
The position and size of the image at 100% zoom level. If undefined the image will be added to the top-left corner with a default size of 250x250 pixels.
Properties
| Name |
Type |
Description |
x |
number
|
The x-coordinate of the top-left corner of the image. |
y |
number
|
The y-coordinate of the top-left corner of the image. |
width |
number
|
The width of the image in pixels. |
height |
number
|
The height of the image in pixels. |
|
Returns:
-
Type
-
Promise.<void>
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 () => {
spreadsheetEditorManager.setEditMode(SpreadsheetEditor.SpreadsheetEditorEditMode.EDITING);
const spreadsheetEditorDocument = documentViewer.getDocument().getSpreadsheetEditorDocument();
const workbook = spreadsheetEditorDocument.getWorkbook();
const sheet = workbook.getSheetAt(0);
await sheet.addImage('./path/to/relative/image.png');
await sheet.addImage('https://www.example.com/image.png');
await sheet.addImage('https://www.example.com/image.png', {
x: 100,
y: 100,
width: 500,
height: 300
});
});
});
-
createColumns(columnIndex, count)
-
Creates new columns and inserts them at the specified index within the sheet.
Parameters:
| Name |
Type |
Description |
columnIndex |
Number
|
A zero-based index at which to start inserting the created columns. |
count |
Number
|
The number of columns to create. |
Returns:
-
Type
-
void
-
createRows(rowIndex, count)
-
Creates new rows with the start point at the specified index, and the count of rows to create.
Parameters:
| Name |
Type |
Description |
rowIndex |
number
|
A zero-based index at which the new rows will be inserted. |
count |
number
|
The number of rows to create. |
Returns:
An array of
rows created.
-
Type
-
Array.<Core.SpreadsheetEditor.Row>
-
getCellAt(rowIndex, columnIndex)
-
Retrieves the cell at the specified row and column index within the sheet. If the cell does not exist, it will be created.
Parameters:
| Name |
Type |
Description |
rowIndex |
|
A zero-based index of the row. |
columnIndex |
|
A zero-based index of the column. |
Returns:
The cell at the specified row and column index.
-
Type
-
Core.SpreadsheetEditor.Cell
-
getColumnWidthInPixel(columnIndex)
-
Retrieves the width of a specified column within the sheet.
Parameters:
| Name |
Type |
Description |
columnIndex |
Number
|
A zero-based index of the column whose width is to be retrieved. |
Returns:
The width of the specified column in pixels.
-
Type
-
Number
-
getImage(index)
-
Retrieves an image at the specified index from the sheet's images collection.
Parameters:
| Name |
Type |
Description |
index |
|
The index of the image to retrieve. |
Returns:
An instance of SpreadsheetEditorImage representing the image at the specified index.
-
Type
-
Core.SpreadsheetEditor.SpreadsheetEditorImage
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, () => {
spreadsheetEditorManager.setEditMode(SpreadsheetEditor.SpreadsheetEditorEditMode.EDITING);
const spreadsheetEditorDocument = documentViewer.getDocument().getSpreadsheetEditorDocument();
const workbook = spreadsheetEditorDocument.getWorkbook();
const sheet = workbook.getSheetAt(0);
const spreadsheetEditorImage = sheet.getImage(0);
console.log(spreadsheetEditorImage);
});
})
-
getRowAt(rowIndex)
-
Retrieves the row at the specified index within the sheet.
Parameters:
| Name |
Type |
Description |
rowIndex |
|
A zero-based index of the row to retrieve from the sheet. |
Returns:
The row at the specified index.
-
Type
-
Core.SpreadsheetEditor.Row
-
getRowHeightInPixel(rowIndex)
-
Retrieves the height of a specified row within the sheet.
Parameters:
| Name |
Type |
Description |
rowIndex |
Number
|
A zero-based index of the row whose height is to be retrieved. |
Returns:
The height of the specified row in pixels.
-
Type
-
Number
-
removeColumns(columnIndex, count)
-
Removes a specific number of columns from a sheet, starting from a given index.
Parameters:
| Name |
Type |
Description |
columnIndex |
Number
|
A zero-based index to start removing columns at. |
count |
Number
|
The number of columns to remove. |
Returns:
-
Type
-
void
-
removeImage(index)
-
Removes an image at the specified index from the sheet's images collection.
Parameters:
| Name |
Type |
Description |
index |
number
|
The 0-based index of the image to remove. |
Example
WebViewer.Iframe(...)
.then(instance => {
const { documentViewer, SpreadsheetEditor } = instance.Core;
const spreadsheetEditorManager = documentViewer.getSpreadsheetEditorManager();
spreadsheetEditorManager.addEventListener(SpreadsheetEditor.SpreadsheetEditorManager.Events.SPREADSHEET_EDITOR_READY, () => {
const spreadsheetEditorDocument = documentViewer.getDocument().getSpreadsheetEditorDocument();
const workbook = spreadsheetEditorDocument.getWorkbook();
const sheet = workbook.getSheetAt(0);
sheet.removeImage(0);
});
})
-
removeRows(rowIndex, count)
-
Removes a specific number of rows from a sheet, starting from a given index.
Parameters:
| Name |
Type |
Description |
rowIndex |
Number
|
A zero-based index to start removing rows at. |
count |
Number
|
The number of rows to remove. |
Returns:
-
Type
-
void
-
setCellRangeBorder(range, border)
-
Sets the border style for a specified border of the cell range.
Parameters:
Returns:
-
Type
-
void
Example
const { Core } = window.getInstance();
const CellRange = Core.SpreadsheetEditor.CellRange;
const workbook = Core.documentViewer.getDocument().getSpreadsheetEditorDocument().getWorkbook();
const sheet = workbook.getSheet('Invoice');
const cellBorder = {
type: 'Top',
style: 'Medium',
color: 'Red'
};
const range = new CellRange({ firstRow: 3, lastRow: 4, firstColumn: 5, lastColumn: 7 });
sheet.setCellRangeBorder(range, cellBorder);
-
setCellRangeStyle(range, style)
-
Applies a cell style to a specified range of cells within the sheet.
Parameters:
Example
const { Core } = window.getInstance();
const CellRange = Core.SpreadsheetEditor.CellRange;
const workbook = Core.documentViewer.getDocument().getSpreadsheetEditorDocument().getWorkbook();
const sheet = workbook.getSheet('Invoice');
const cellStyle = workbook.createCellStyle({
backgroundColor: 'red',
verticalAlignment: 1,
horizontalAlignment: 1,
wrapText: 2,
});
const range = new CellRange({ firstRow: 3, lastRow: 4, firstColumn: 5, lastColumn: 7 });
sheet.setCellRangeStyle(range, cellStyle);
-
setColumnWidthInPixel(columnIndex, width)
-
Adjusts the width of a specified column within the sheet, measured in pixels.
Parameters:
| Name |
Type |
Description |
columnIndex |
Number
|
A zero-based index of the column. |
width |
Number
|
The new width, in pixels. |
-
setRowHeightInPixel(rowIndex, height)
-
Adjusts the height of a specified row within the sheet, measured in pixels.
Parameters:
| Name |
Type |
Description |
rowIndex |
Number
|
A zero-based index of the row. |
height |
Number
|
The new height, in pixels. |
Returns:
-
Type
-
void