Kalkylarksredigerare - Arbeta med Cells

Innehållsförteckning

  • Välj en Cell
  • Cell valåteruppringning
  • Ta bort ett Cell
  • WorksheetView.removeCellShiftUp
  • WorksheetView.removeCellShiftLeft
  • Rensa en Cell WorksheetView.clearCurrentCellFormatting
  • WorksheetView.clearCurrentCellContents
  • WorksheetView.clearCurrentCell

Välj en Cell

Använd muspekaren för att peka på en cell. Klicka på en cell för att markera den. Den markerade cellen är markerad med en fet rektangel.

Hur det fungerar?

När användaren klickar på en cell hanteras händelsen av JavaScript-återuppringningsfunktionen som är kopplad till Primefaces-komponenten.

Cell val återuppringning

                     var columnId = $(this).find('.ui-cell-editor-input input').attr('data-columnid');

                    var rowId = $(this).find('.ui-cell-editor-input input').attr('data-rowid');

                    var clientId = $(this).find('.ui-cell-editor').attr('id');

                    PF('currentColumnIdValue').jq.val(columnId);

                    PF('currentRowIdValue').jq.val(rowId);

                    PF('currentCellClientIdValue').jq.val(clientId);

                    if ($(this).find('.ui-cell-editor-output div').hasClass('b')) {

                        PF('boldOptionButton').check();

                    } else {

                        PF('boldOptionButton').uncheck();

                    }

                    if ($(this).find('.ui-cell-editor-output div').hasClass('i')) {

                        PF('italicOptionButton').check();

                    } else {

                        PF('italicOptionButton').uncheck();

                    }

                    if ($(this).find('.ui-cell-editor-output div').hasClass('u')) {

                        PF('underlineOptionButton').check();

                    } else {

                        PF('underlineOptionButton').uncheck();

                    }

                    PF('fontOptionSelector').selectValue($(this).find('.ui-cell-editor-output div').css('font-family').slice(1, -1));

                    PF('fontSizeOptionSelector').selectValue($(this).find('.ui-cell-editor-output div')[0].style.fontSize.replace('pt', ''));

                    ['al', 'ac', 'ar', 'aj'].forEach(function(v) {

                        if ($(this).find('.ui-cell-editor-output div').hasClass(v)) {

                            // TODO: save the value to PF('alignOptionSelector');

                        }

                    });

                    PF('currentColumnWidthValue').jq.val($(this).width());

                    PF('currentRowHeightValue').jq.val($(this).height());

                    $($this.selectedCell).removeClass('sheet-selected-cell');

                    $(this).addClass('sheet-selected-cell');

                    $this.selectedCell = this;

Ta bort ett Cell

Så här tar du bort en cell:

  1. Klicka på en cell du vill ta bort.
  2. Byta tillFliken Format.
  3. KlickRadera Cell knapp.
  4. VäljaSkift Cells Upp ellerSkift Cells Vänster knapp.

Redaktören tar bort den markerade cellen. De intilliggande cellerna kommer automatiskt att flyttas antingen horisontellt eller vertikalt för att justera utrymmet.

Hur det fungerar?

DeSkift Cells Upp ochSkift Cells Vänster hanteras av JSF backend beanArbetsbladsvy. Källkoden för respektive metoder är följande:

WorksheetView.removeCellShiftUp

     public void removeCellShiftUp() {

        if (!isLoaded()) {

            return;

        }

        getAsposeWorksheet().getCells().deleteRange(currentRowId, currentColumnId, currentRowId, currentColumnId, com.aspose.cells.ShiftType.UP);

        purge();

    }

WorksheetView.removeCellShiftLeft

     public void removeCellShiftLeft() {

        if (!isLoaded()) {

            return;

        }

        getAsposeWorksheet().getCells().deleteRange(currentRowId, currentColumnId, currentRowId, currentColumnId, com.aspose.cells.ShiftType.LEFT);

        purge();

    }

Rensa en Cell

Så här rensar du en cell:

  1. Klicka på en cell du vill rensa.
  2. Byta tillFliken Format.
  3. KlickRensa Cell knapp.
  4. VäljaFormat, Innehåll ellerBåde alternativ.

Redaktören rensar den markerade cellen.

Hur det fungerar?

DeFormat, Innehåll ochBåde hanteras av JSF backend beanArbetsbladsvy. Källkoden för respektive metoder är följande:

WorksheetView.clearCurrentCellFormatting

     public void clearCurrentCellFormatting() {

        if (!isLoaded()) {

            return;

        }

        getAsposeWorksheet().getCells().clearFormats(currentRowId, currentColumnId, currentRowId, currentColumnId);

        reloadCell(currentColumnId, currentRowId);

        RequestContext.getCurrentInstance().update(currentCellClientId);

    }

WorksheetView.clearCurrentCellContents

     public void clearCurrentCellContents() {

        if (!isLoaded()) {

            return;

        }

        getAsposeWorksheet().getCells().clearContents(currentRowId, currentColumnId, currentRowId, currentColumnId);

        reloadCell(currentColumnId, currentRowId);

        RequestContext.getCurrentInstance().update(currentCellClientId);

    }

WorksheetView.clearCurrentCell

     public void clearCurrentCell() {

        if (!isLoaded()) {

            return;

        }

        getAsposeWorksheet().getCells().clearRange(currentRowId, currentColumnId, currentRowId, currentColumnId);

        reloadCell(currentColumnId, currentRowId);

        RequestContext.getCurrentInstance().update(currentCellClientId);

    }