Uploaded image for project: 'ZK Spreadsheet'
  1. ZK Spreadsheet
  2. ZSS-22

Shall not allow Copy and Paste operation in a protected spreadsheet

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 2.2.0
    • None
    • None
    • None

      http://code.google.com/p/zkspreadsheet/issues/detail?id=351

      Reported by Andreas Boos.

      Hi.

      How can I prevent a user from running ctrl + c ctrl + v in a spreadsheet? I tried to intercept the keys (ctrl+c, ctrl+v,shift+inx,ctrl+ins) and "do nothing" but not worked.

      Another thing, when the sheet is locked you can still do ctrl + c/x ctrl + v between cells. Is this normal?

      I lock the spreadsheet using this code:

      Spreadsheet s;

      Ranges.range(s.getSelectedSheet()).protectSheet("testing123");

      int topRow = 0;
      int bottomRow = 6;
      int leftCol = 0;
      int rightCol = 7;

      void toggleLockCells() {
      final Worksheet sheet = s.getSelectedSheet();
      for (int r = topRow; r <= bottomRow; r++) {
      for (int c = leftCol; c <= rightCol; c++) {
      org.zkoss.poi.ss.usermodel.Cell cell = (org.zkoss.poi.ss.usermodel.Cell)Utils.getOrCreateCell(sheet, r, c);
      org.zkoss.poi.ss.usermodel.CellStyle cellStyle = (org.zkoss.poi.ss.usermodel.CellStyle)cell.getCellStyle();
      if (cellStyle.getLocked() != lock) {
      org.zkoss.poi.ss.usermodel.CellStyle newCellStyle = sheet.getBook().createCellStyle();
      newCellStyle.setLocked(true);
      Ranges.range(sheet, r, c).setStyle(newCellStyle);
      System.out.println("row : " + r + " - c : " + c);
      }
      }
      }
      }

      I'm using version 2.1.0.

      Thanks

            Unassigned Unassigned
            henrichen henrichen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: