[]
Sheets.Collaboration.Collaboration
• new Collaboration(workbook)
Represents a collaboration manager that can manage collaboration status.
| Name | Type | Description |
|---|---|---|
workbook |
Workbook |
The workbook. |
▸ applyChangeSet(changeSet): void
Only used in collaboration case, to apply doc's op.
| Name | Type | Description |
|---|---|---|
changeSet |
IChangeSet |
change set |
void
▸ endBatchOp(): void
Ends the current batch operation, finalizing the collection of operations into a single ChangeSet.
This method must be called after startBatchOp to complete the batch process.
example
spread.collaboration.startBatchOp();
sheet.setValue(0, 1, "World");
sheet.setFormula(0, 2, "=SUM(A1:B1)");
spread.collaboration.endBatchOp(); // The value and formula changes are merged into one ChangeSet.
void
▸ fromSnapshot(snapshot): void
Only used in collaboration case, to restore the snapshot to workbook state.
| Name | Type | Description |
|---|---|---|
snapshot |
Object |
snapshot object |
void
▸ getPresences(): IPresence[]
Get presences for workbook
example
// This example gets presences.
const presences = spread.collaboration.getPresences();
presences - The presences info.
▸ getUser(): IUser
Get user for workbook
example
// this example gets the current user.
const user = spread.collaboration.getUser();
▸ onChangeSet(onOpHandler): void
Only used in collaboration case, to watch change set.
| Name | Type | Description |
|---|---|---|
onOpHandler |
IChangeSetHandler |
callback to watch change set |
void
▸ registerCollaborationType(type): void
Only used in collaboration case, to register collaboration type.
| Name | Type | Description |
|---|---|---|
type |
IOT_Type |
collaboration type |
void
▸ setPresences(presences): void
Set the presences info.
example
//This example updates the current presences.
let presences = [{
user: {
id: '1',
name: 'User1',
color: '#FF0000',
permission: {
mode: GC.Spread.Sheets.Collaboration.BrowsingMode.edit,
}
},
status: {
selections: {
selections: [new GC.Spread.Sheets.Range(0, 0, 1, 1)],
sheetId: 'sheet1'
}
}
}, {
user: {
id: '2',
name: 'User2',
permission: {
mode: GC.Spread.Sheets.Collaboration.BrowsingMode.edit,
}
},
status: {
selections: {
selections: [new GC.Spread.Sheets.Range(2, 2, 3, 5)],
sheetId: 'sheet1'
}
}
}]
spread.collaboration.setPresences(presences);
| Name | Type | Description |
|---|---|---|
presences |
IPresence[] |
The presences info. |
void
▸ setUser(user): void
Sets the current user.
example
//This example sets the current user.
let user = {
id: '1',
name: 'User1',
color: '#FF0000',
permission: {
mode: GC.Spread.Sheets.Collaboration.BrowsingMode.edit,
}
}
spread.collaboration.setUser(user);
| Name | Type | Description |
|---|---|---|
user |
IUser |
The current user. |
void
▸ startBatchOp(): void
Starts a batch operation, allowing multiple operations to be grouped and merged into a single ChangeSet.
When called, all operations performed until endBatchOp is invoked are collected and treated as a single atomic change in the SpreadJS workbook.
example
spread.collaboration.startBatchOp();
sheet.setValue(0, 0, "Hello");
sheet.setFormula(0, 2, "=SUM(A1:B1)");
spread.collaboration.endBatchOp(); // All operations above are merged into a single ChangeSet.
void
▸ toSnapshot(): Object
Only used in collaboration case, to save workbook state to snapshot.
Object
snapshot - snapshot object