[]
        
(Showing Draft Content)

IDisplayFormat

Interface IDisplayFormat


public interface IDisplayFormat
Represents the display settings for an associated IRange.

Actions such as changing the conditional formatting or table style of a range can cause what is displayed in the current user interface to be inconsistent with the values in the corresponding properties of the IRange object. Use the properties of this interface to return the values as they are displayed in the current user interface.


 IRange range = worksheet.getRange("A1");
 range.setValue(1234.56);
 range.setNumberFormat("$#,##0.00");
 range.getBorders().get(BordersIndex.EdgeBottom).setLineStyle(BorderLineStyle.Thin);
 IFormatCondition condition = (IFormatCondition) range.getFormatConditions().add(
     FormatConditionType.CellValue, FormatConditionOperator.Greater, "1000", null);
 condition.setNumberFormat("0.00%");
 condition.getBorders().get(BordersIndex.EdgeBottom).setLineStyle(BorderLineStyle.Thick);
 IDisplayFormat displayFormat = range.getDisplayFormat();
 String numberFormat = displayFormat.getNumberFormat();
 IBorders borders = displayFormat.getBorders();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Gets a value that indicates whether the application automatically indents text of the associated IRange when the text alignment in a cell is set to equal distribution, either horizontally or vertically, as it is displayed in the current user interface.
    Gets a Borders object that represents the borders of the associated IRange object as it is displayed in the current user interface.
    Gets a Font object that represents the font of the associated IRange as it is displayed in the current user interface.
    boolean
    Gets a value that indicates if the formula of the associated IRange object is hidden when the worksheet is protected as it is displayed in the current user interface.
    Gets a value that represents the horizontal alignment of the associated IRange object as it is displayed in the current user interface.
    int
    Gets a value that represents the indent level of the associated IRange object as it is displayed in the current user interface.
    Gets an Interior object that represents the interior of the associated IRange object as it is displayed in the current user interface.
    boolean
    Gets a value that indicates whether the associated IRange is locked as it is displayed in the current user interface.
    boolean
    Gets a value that indicates whether the associated IRange object contains merged cells as it is displayed in the current user interface.
    Gets a value that represents the format code of the associated IRange object as it is displayed in the current user interface.
    int
    Gets a value that represents the text orientation of the associated IRange object as it is displayed in the current user interface.
    Gets the reading order of the associated IRange object as it is displayed in the current user interface.
    boolean
    Gets a value that indicates if the application automatically shrinks text to fit in the available column width of the associated IRange object as it is displayed in the current user interface.
    Gets the IStyle object associated with the range.
    Gets a value that represents the vertical alignment of the associated IRange object as it is displayed in the current user interface.
    boolean
    Gets a value that indicates if the application wraps the text of the associated IRange object as it is displayed in the current user interface.
  • Method Details

    • getAddIndent

      boolean getAddIndent()
      Gets a value that indicates whether the application automatically indents text of the associated IRange when the text alignment in a cell is set to equal distribution, either horizontally or vertically, as it is displayed in the current user interface.

      This property reflects the displayed format of the associated range, which can differ from the underlying range settings.

      
       IRange range = worksheet.getRange("A1");
       range.setValue("Test");
       range.setHorizontalAlignment(HorizontalAlignment.Distributed);
       range.setAddIndent(true);
       boolean addIndent = range.getDisplayFormat().getAddIndent();
       
      Returns:
      true if text is automatically indented when the text alignment in the cell is set, either horizontally or vertically, to equal distribution; otherwise, false.
    • getBorders

      IBorders getBorders()
      Gets a Borders object that represents the borders of the associated IRange object as it is displayed in the current user interface.

      The returned IBorders reflects the displayed border settings of the associated range. These displayed settings can differ from the corresponding border properties of the range itself when the current appearance is affected by features such as conditional formatting or table styles. Use IRange.getDisplayFormat() to read the border settings as they appear in the user interface.

      
       IRange cell = worksheet.getRange("A1");
       cell.setValue(1234.56);
       cell.getBorders().get(BordersIndex.EdgeBottom).setLineStyle(BorderLineStyle.Thin);
       IFormatCondition condition = (IFormatCondition) cell.getFormatConditions().add(
           FormatConditionType.CellValue, FormatConditionOperator.Greater, "1000", null);
       condition.getBorders().get(BordersIndex.EdgeBottom).setLineStyle(BorderLineStyle.Thick);
       IBorders borders = cell.getDisplayFormat().getBorders();
       IBorder bottomBorder = borders.get(BordersIndex.EdgeBottom);
       
      Returns:
      The IBorders object that represents the displayed borders of the associated range.
    • getFont

      IFont getFont()
      Gets a Font object that represents the font of the associated IRange as it is displayed in the current user interface.

      The returned IFont reflects the displayed font of the associated IRange. This displayed font can differ from the underlying font settings of the range when the current appearance is affected by features such as conditional formatting, table styles, or number formats.

      
       IRange range = worksheet.getRange("A1");
       range.setValue(1234.56);
       range.getFont().setColor(Color.GetBlack());
       IFormatCondition condition = (IFormatCondition) range.getFormatConditions().add(
           FormatConditionType.CellValue, FormatConditionOperator.Greater, "1000", null);
       condition.getFont().setColor(Color.GetBlue());
       IFont font = range.getDisplayFormat().getFont();
       Color color = font.getColor();
       
      Returns:
      The IFont object that represents the displayed font of the associated range.
    • getFormulaHidden

      boolean getFormulaHidden()
      Gets a value that indicates if the formula of the associated IRange object is hidden when the worksheet is protected as it is displayed in the current user interface.

      This property returns the displayed protection setting for the associated range. Use IRange.setFormulaHidden(boolean) to hide formulas when the worksheet is protected.

      
       IRange range = worksheet.getRange("A1");
       range.setFormula("=SUM(B1:B2)");
       range.setFormulaHidden(true);
       boolean formulaHidden = range.getDisplayFormat().getFormulaHidden();
       
      Returns:
      true if the formula is hidden when the worksheet is protected and displayed in the current user interface; otherwise, false.
    • getHorizontalAlignment

      HorizontalAlignment getHorizontalAlignment()
      Gets a value that represents the horizontal alignment of the associated IRange object as it is displayed in the current user interface.

      Use this method to retrieve the effective horizontal alignment shown in the user interface, which can differ from the corresponding IRange property when conditional formatting or table styles are applied.

      
       IRange range = worksheet.getRange("A1");
       range.setValue("Test");
       range.setHorizontalAlignment(HorizontalAlignment.Center);
       HorizontalAlignment alignment = range.getDisplayFormat().getHorizontalAlignment();
       
      Returns:
      A HorizontalAlignment value that indicates the horizontal alignment of the associated IRange object as displayed in the current user interface.
    • getIndentLevel

      int getIndentLevel()
      Gets a value that represents the indent level of the associated IRange object as it is displayed in the current user interface.

      Use this method to retrieve the effective indent level shown for the range, which can differ from the range's own formatting properties when display-affecting features such as conditional formatting are applied.

      
       IRange range = worksheet.getRange("A1");
       range.setValue("Test");
       range.setIndentLevel(2);
       int indentLevel = range.getDisplayFormat().getIndentLevel();
       
      Returns:
      The indent level of the associated IRange object as displayed in the current user interface.
    • getInterior

      IInterior getInterior()
      Gets an Interior object that represents the interior of the associated IRange object as it is displayed in the current user interface.

      The returned IInterior reflects the displayed fill settings of the associated IRange. These displayed settings can differ from the corresponding interior properties of the range itself when the current appearance is affected by features such as conditional formatting or table styles. Use IRange.getDisplayFormat() to read the interior settings as they appear in the user interface.

      
       IRange range = worksheet.getRange("A1");
       range.setValue(1234.56);
       range.getInterior().setColor(Color.GetYellow());
       IFormatCondition condition = (IFormatCondition) range.getFormatConditions().add(
           FormatConditionType.CellValue, FormatConditionOperator.Greater, "1000", null);
       condition.getInterior().setColor(Color.GetBlue());
       IInterior interior = range.getDisplayFormat().getInterior();
       Color color = interior.getColor();
       
      Returns:
      The IInterior object that represents the displayed interior of the associated range.
    • getLocked

      boolean getLocked()
      Gets a value that indicates whether the associated IRange is locked as it is displayed in the current user interface.

      This property returns the displayed protection setting for the associated range.

      
       IRange range = worksheet.getRange("A1");
       range.setValue("Test");
       range.setLocked(true);
       boolean locked = range.getDisplayFormat().getLocked();
       
      Returns:
      true if the associated range is locked as displayed in the current user interface; otherwise, false.
    • getMergeCells

      boolean getMergeCells()
      Gets a value that indicates whether the associated IRange object contains merged cells as it is displayed in the current user interface.
      
       IRange range = worksheet.getRange("A1:B1");
       range.setValue("Test");
       range.merge();
       boolean mergeCells = range.getDisplayFormat().getMergeCells();
       
      Returns:
      true if the associated IRange object contains merged cells; otherwise, false.
    • getNumberFormat

      String getNumberFormat()
      Gets a value that represents the format code of the associated IRange object as it is displayed in the current user interface.

      Use this method to retrieve the effective number format currently shown for the range. This displayed format can differ from the range's own format settings when display-affecting features such as conditional formatting or table styles are applied.

      
       IRange range = worksheet.getRange("A1");
       range.setNumberFormat("$#,##0.00");
       range.setValue(1234.5);
       String numberFormat = range.getDisplayFormat().getNumberFormat();
       
      Returns:
      The format code of the associated IRange object as displayed in the current user interface.
    • getOrientation

      int getOrientation()
      Gets a value that represents the text orientation of the associated IRange object as it is displayed in the current user interface.

      The returned value represents the displayed text rotation in degrees. It follows the same orientation values as IRange.getOrientation(), such as values from -90 to 90, or 255 for vertical text.

      
       IRange range = worksheet.getRange("A1");
       range.setValue("Test");
       range.setOrientation(45);
       int orientation = range.getDisplayFormat().getOrientation();
       
      Returns:
      The text orientation of the associated IRange object as displayed in the current user interface.
    • getReadingOrder

      ReadingOrder getReadingOrder()
      Gets the reading order of the associated IRange object as it is displayed in the current user interface.

      This value reflects the displayed format of the range and can differ from the corresponding IRange property when the displayed result is affected by formatting such as conditional formatting or table styles.

      
       IRange range = worksheet.getRange("A1");
       range.setValue("Test");
       range.setReadingOrder(ReadingOrder.RightToLeft);
       ReadingOrder readingOrder = range.getDisplayFormat().getReadingOrder();
       
      Returns:
      The displayed ReadingOrder of the associated IRange object.
    • getShrinkToFit

      boolean getShrinkToFit()
      Gets a value that indicates if the application automatically shrinks text to fit in the available column width of the associated IRange object as it is displayed in the current user interface.

      This property reflects the displayed format of the associated range, which can differ from the underlying range settings.

      
       IRange range = worksheet.getRange("A1");
       range.setValue("Long text");
       range.setShrinkToFit(true);
       boolean shrinkToFit = range.getDisplayFormat().getShrinkToFit();
       
      Returns:
      true if the application automatically shrinks text to fit in the available column width of the associated range as displayed in the current user interface; otherwise, false.
    • getStyle

      IStyle getStyle()
      Gets the IStyle object associated with the range.

      The returned style is the range's underlying style object. Display-only changes introduced by conditional formatting or table styles are not merged into this style object. To read values as they are currently displayed in the user interface, use other IDisplayFormat members such as getNumberFormat(), getFont(), or getBorders().

      
       IStyle currencyStyle = workbook.getStyles().add("CurrencyStyle");
       currencyStyle.setNumberFormat("$#,##0.00");
       IRange range = worksheet.getRange("A1");
       range.setValue(1234.56);
       range.setStyle(currencyStyle);
       IFormatCondition condition = (IFormatCondition) range.getFormatConditions().add(
           FormatConditionType.CellValue, FormatConditionOperator.Greater, "1000", null);
       condition.setNumberFormat("0.00%");
       IStyle style = range.getDisplayFormat().getStyle();
       String baseNumberFormat = style.getNumberFormat();
       String displayedNumberFormat = range.getDisplayFormat().getNumberFormat();
       
      Returns:
      The IStyle object associated with the range.
    • getVerticalAlignment

      VerticalAlignment getVerticalAlignment()
      Gets a value that represents the vertical alignment of the associated IRange object as it is displayed in the current user interface.

      Use this property to retrieve the effective vertical alignment shown for the range, which can differ from the corresponding range property when display settings are affected by features such as conditional formatting or table styles.

      
       IRange range = worksheet.getRange("A1");
       range.setValue("Test");
       range.setVerticalAlignment(VerticalAlignment.Center);
       VerticalAlignment alignment = range.getDisplayFormat().getVerticalAlignment();
       
      Returns:
      The displayed vertical alignment of the associated range.
    • getWrapText

      boolean getWrapText()
      Gets a value that indicates if the application wraps the text of the associated IRange object as it is displayed in the current user interface.

      This property reflects the displayed format of the associated range, which can differ from the underlying IRange settings.

      
       IRange range = worksheet.getRange("A1");
       range.setValue("Test");
       range.setWrapText(true);
       boolean wrapText = range.getDisplayFormat().getWrapText();
       
      Returns:
      true if the application wraps the text of the associated range as displayed in the current user interface; otherwise, false.