Package org.zkoss.zss.model

Examples of org.zkoss.zss.model.Book


  @Override
  public void deleteSheet() {
    synchronized (_sheet.getBook()) {
      Ref ref = _refs != null && !_refs.isEmpty() ? _refs.iterator().next() : null;
      if (ref != null) {
        final Book book = _sheet.getBook();
        if (book != null) {
          final int index = book.getSheetIndex(_sheet);
          if (index != -1) {
            final int sheetCount = book.getNumberOfSheets();
            if (sheetCount == 1) {
              Messagebox.show("A workbook must contain at least one visible worksheet");
            }
            final String delSheetName = _sheet.getSheetName(); //must getName before remove
            book.removeSheetAt(index);
            final int newIndex =  index < (sheetCount - 1) ? index : (index - 1);
            final String newSheetName = book.getSheetName(newIndex);
            BookHelper.notifyDeleteSheet(ref, new Object[] {delSheetName, newSheetName});
          }
        }
      }
    }
View Full Code Here


  private void myAddDependency(CellRefImpl srcRef, String refBookname,
    String refSheetname, String refLastSheetName, int tRow, int lCol, int bRow, int rCol) {
    if ("#REF".equals(refSheetname) || "#REF".equals(refLastSheetName)) { //handle refer to deleted sheet
      return;
    }
    final Book targetBook = BookHelper.getBook(_book, refBookname);
    if (targetBook == null) {
      throw new UiException("cannot find the named book, have you add it in the Books:"+ refBookname);
    }
    final RefBook targetRefBook = BookHelper.getOrCreateRefBook(targetBook);
   
    final int s1 = targetBook.getSheetIndex(refSheetname);
    final int s2 = targetBook.getSheetIndex(refLastSheetName);
    final int sheetIndex1 = Math.min(s1, s2);
    final int sheetIndex2 = Math.max(s1, s2);
    for(int j = sheetIndex1; j <= sheetIndex2; ++j) {
      final String sheetname = targetBook.getSheetName(j);
      final RefSheet targetRefSheet = targetRefBook.getOrCreateRefSheet(sheetname);
      DependencyTrackerHelper.addDependency(srcRef, targetRefSheet, tRow, lCol, bRow, rCol);
    }
  }
View Full Code Here

        Importer importer = _importer;
        if (importer == null) {
          importer = new ExcelImporter();
        }

        Book book = null;
        if (importer instanceof ExcelImporter) {
          URL url = null;
         
          if (_src.startsWith("/")) {// try to load by application
            // context.
View Full Code Here

    //setRowfreeze(-1);
    //setColumnfreeze(-1);
    //setBook(null);
    _importer = new ExcelImporter();
    _src=src;
    final Book book = ((ExcelImporter)_importer).imports(is, src);
    initBook(book);
    invalidate();
  }
View Full Code Here

  /**
   * Gets the selected sheet, the default selected sheet is first sheet.
   * @return #{@link Worksheet}
   */
  public Worksheet getSelectedSheet() {
    final Book book = getBook();
    if (book == null) {
      return null;
    }
    if (_selectedSheet == null) {
      if (_selectedSheetId == null) {
        if (book.getNumberOfSheets() == 0)
          throw new UiException("sheet size of given book is zero");
        _selectedSheet = (Worksheet) book.getSheetAt(0);
        _selectedSheetId = Utils.getSheetUuid(_selectedSheet);
      } else {
        _selectedSheet = Utils.getSheetByUuid(_book, _selectedSheetId);
        if (_selectedSheet == null) {
          throw new UiException("can not find sheet by id : "  + _selectedSheetId);
View Full Code Here

    }
    return _selectedSheet;
  }

  public Worksheet getSheet(int index){
    final Book book = getBook();
    return book != null ? (Worksheet)book.getSheetAt(index) : null;
  }
View Full Code Here

    final Book book = getBook();
    return book != null ? (Worksheet)book.getSheetAt(index) : null;
  }
 
  public int indexOfSheet(Worksheet sheet){
    final Book book = getBook();
    return book != null ? book.getSheetIndex(sheet) : -1;
  }
View Full Code Here

   * it will change the spreadsheet src name as src
   * and book name as src => will not reload the book
   * @param src
   */
  public void setSrcName(String src) {
    /**
     * TODO model integration
     */
    /*
    BookImpl book = (BookImpl) this.getBook();
    if (book != null)
View Full Code Here

    doSheetSelected(_selectedSheet);
    invalidate();
  }
 
  private void setSelectedSheetImpl(String name) {
    final Book book = getBook();
    if (book == null) {
      return;
    }
   
    //Note. check whether if the sheet has remove or not
    if (_selectedSheet != null && book.getSheetIndex(_selectedSheet) == -1) {
      doSheetClean(_selectedSheet);
      _selectedSheet = null;
      _selectedSheetId = null;
      _selectedSheetName = null;
    }

    if (_selectedSheet == null || !_selectedSheet.getSheetName().equals(name)) {
      Worksheet sheet = book.getWorksheet(name);
      if (sheet == null) {
        throw new UiException("No such sheet : " + name);
      }

      if (_selectedSheet != null)
View Full Code Here

   
    return new ChangeInfo(last, all, changeMerges);
  }
 
  private static ChangeInfo insertXSSFColumns(Worksheet sheet, int startCol, int num, int copyOrigin) {
    final Book book = (Book) sheet.getWorkbook();
    final RefSheet refSheet = getRefSheet(book, sheet);
    final Set<Ref>[] refs = refSheet.insertColumns(startCol, num);
    final List<CellRangeAddress[]> shiftedRanges = ((XSSFSheetImpl)sheet).shiftColumnsOnly(startCol, -1, num, true, false, true, false, copyOrigin);
    final List<MergeChange> changeMerges = prepareChangeMerges(refSheet, shiftedRanges);
    final Set<Ref> last = refs[0];
    final Set<Ref> all = refs[1];
    final int maxrow = book.getSpreadsheetVersion().getLastRowIndex();
    final int maxcol = book.getSpreadsheetVersion().getLastColumnIndex();
    shiftFormulas(all, sheet, 0, maxrow, 0, startCol, maxcol, num);
   
    return new ChangeInfo(last, all, changeMerges);
  }
View Full Code Here

TOP

Related Classes of org.zkoss.zss.model.Book

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.