You can enable Collaboration Editing if you specify two or more Spreadsheet components to share a same book model within the appropriate scope.
<?xml version="1.0" encoding="UTF-8"?> <div apply="demo.collaboration_edit.CoeditController"> <hlayout style="overflow-x: auto"> <panel title="Steve Ray's Workspace" border="normal" hflex="1"> <panelchildren style="padding: 8px"> <label value="Practice Room Reservation" style="padding-left:16px;font-size:16px" /> <separator bar="true" style="margin:8px 8px 16px 16px" /> <spreadsheet id="steveSpreadsheet" maxVisibleRows="9" maxVisibleColumns="6" height="270px"/> </panelchildren> </panel> <panel title="Jimmy Hundred's Workspace" border="normal" hflex="1" > <panelchildren style="padding: 8px"> <label value="Practice Room Reservation" style="padding-left:16px;font-size:16px" /> <separator bar="true" style="margin:8px 8px 16px 16px" /> <spreadsheet id="jimmySpreadsheet" maxVisibleRows="9" maxVisibleColumns="6" height="270px" /> </panelchildren> </panel> </hlayout> </div>
package demo.collaboration_edit; import java.io.IOException; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.WebApps; import org.zkoss.zk.ui.event.EventQueues; import org.zkoss.zk.ui.select.SelectorComposer; import org.zkoss.zk.ui.select.annotation.Wire; import io.keikai.api.Importer; import io.keikai.api.Importers; import io.keikai.api.model.Book; import io.keikai.ui.Spreadsheet; public class CoeditController extends SelectorComposer<Component> { @Wire private Spreadsheet steveSpreadsheet, jimmySpreadsheet; public void doAfterCompose(Component comp) throws Exception { Book book; super.doAfterCompose(comp); final Importer importer = Importers.getImporter(); try { book = importer.imports(WebApps.getCurrent().getResource("/WEB-INF/books/practice_room_reservation.xlsx"), "practice_room_reservation.xlsx"); } catch (IOException exception) { throw new RuntimeException(exception.getMessage(), exception); } if (book != null) { book.setShareScope(EventQueues.APPLICATION); steveSpreadsheet.setBook(book); steveSpreadsheet.setUserName("SteveRay"); jimmySpreadsheet.setBook(book); jimmySpreadsheet.setUserName("JimmyHundred"); } } }