[]
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
▸ getPermission(): IPermission
Gets the current workbook permission info.
example
//This example gets the current workbook permission info.
let permission = spread.collaboration.getPermission(permission);
permission The permission info of this workbook.
▸ getPresences(): IPresence[]
Get presences for workbook
example
// This example gets presences.
const presences = spread.collaboration.getPresences();
presences - The presences info.
▸ getUser(): IUserWithPermission
Get user info and permission info for workbook
deprecated since version 19.0.0, This method has been deprecated, to user this method, please use GC.Spread.Common.UserManager.get(GC.Spread.Common.UserManager.current()) and spread.collaboration.getPermission.
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
▸ setPermission(permission): void
Sets the current workbook permission info.
example
//This example sets the current workbook permission info.
let permission = {
mode: GC.Spread.Sheets.Collaboration.BrowsingMode.edit,
}
spread.collaboration.setPermission(permission);
| Name | Type | Description |
|---|---|---|
permission |
IPermission |
The permission info of this workbook. |
void
▸ setPresences(presences): void
Set the presences info.
example
//This example updates the current presences.
let presences = [{
user: {
id: '1',
name: 'User1',
color: '#FF0000'
},
status: {
selections: {
selections: [new GC.Spread.Sheets.Range(0, 0, 1, 1)],
sheetId: 'sheet1'
}
}
}, {
user: {
id: '2',
name: 'User2'
},
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 and permission.
deprecated since version 19.0.0, This method has been deprecated, to user this method, please use GC.Spread.Common.UserManager.current and spread.collaboration.setPermission.
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 |
IUserWithPermission |
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