Class DefaultHyperlinkCellClickHandler

java.lang.Object
com.vaadin.flow.component.spreadsheet.DefaultHyperlinkCellClickHandler
All Implemented Interfaces:
Spreadsheet.HyperlinkCellClickHandler, Serializable

public class DefaultHyperlinkCellClickHandler extends Object implements Spreadsheet.HyperlinkCellClickHandler
Default implementation of the Spreadsheet.HyperlinkCellClickHandler interface. Handles links to cells in either the same or some other sheet, as well as external URLs.
Since:
1.0
Author:
Vaadin Ltd.
See Also:
  • Constructor Details

  • Method Details

    • getSpreadsheet

      protected Spreadsheet getSpreadsheet()
      expose for subclasses
      Returns:
      Spreadsheet for this handler
    • getOpenStyle

      expose for subclasses
      Returns:
      the openStyle
    • setOpenStyle

      public void setOpenStyle(DefaultHyperlinkCellClickHandler.HyperlinkOpenStyle openStyle)
      Parameters:
      openStyle - the openStyle to set (uses NewTab if null)
    • onHyperLinkCellClick

      public void onHyperLinkCellClick(org.apache.poi.ss.usermodel.Cell cell, org.apache.poi.ss.usermodel.Hyperlink hyperlink)
      Called when a hyperlink cell has been clicked.
      Specified by:
      onHyperLinkCellClick in interface Spreadsheet.HyperlinkCellClickHandler
      Parameters:
      cell -
      hyperlink - may be null, only for Excel link relations, not formula
    • getHyperlinkFunctionTarget

      public String getHyperlinkFunctionTarget(org.apache.poi.ss.usermodel.Cell cell)
      Should only be called for cells isHyperlinkFormulaCell(Cell) returns true. Returns the target for tooltip use by default.

      The address is inside the first argument: HYPERLINK("address","friendly name") or HYPERLINK("#!viewName[/arguments]","friendly name") or HYPERLINK(D5,"friendly name") or HYPERLINK([arbitrary formula],"friendly name")

      Specified by:
      getHyperlinkFunctionTarget in interface Spreadsheet.HyperlinkCellClickHandler
      Parameters:
      cell - Target cell containing a hyperlink function
      Returns:
      the address that the hyperlink function points to
    • getFirstArgumentFromFormula

      protected String getFirstArgumentFromFormula(org.apache.poi.ss.usermodel.Cell cell)
      we parse the formula with a formula/POI trick so we don't have to use tricky regular expressions that hit terminal runaway evaluation cases see: https://www.regular-expressions.info/catastrophic.html Instead, translate
       HYPERLINK(arg1[, arg2])
       to
       IF(true, arg1[, arg2])
       
    • isHyperlinkFormulaCell

      public static final boolean isHyperlinkFormulaCell(org.apache.poi.ss.usermodel.Cell cell)
      Returns true if the cell contains a hyperlink function.
      Parameters:
      cell - Cell to investigate
      Returns:
      True if hyperlink is found
    • openExternalLink

      protected void openExternalLink(String address)
      Uses the DefaultHyperlinkCellClickHandler.HyperlinkOpenStyle to open link addresses. Subclass and override to use something else with the address.
      Parameters:
      address - to navigate to