.. _style-c-api:

Style API Reference
===================

Overview
--------

The Style API provides functions to manage cell formatting styles
in Excel worksheets, including number formats, fonts, borders,
fills, alignment, and protection settings.

Number Formatting
-----------------

.. c:function:: int style_set_numfmt(StyleHandle style, const char* numFmtCode)

    Set custom number format code.

    :param style: Style handle.
    :param numFmtCode: Number format code string.
    :return: 1 on success, 0 on failure.

.. c:function:: const char* style_numfmt_code(StyleHandle style)

    Get number format code.

    :param style: Style handle.
    :return: Number format code string.

.. c:function:: int style_numfmt_id(StyleHandle style)

    Get number format ID.

    :param style: Style handle.
    :return: Number format ID.

.. c:function:: int style_set_numfmt_id(StyleHandle style, int numFmtId)

    Set number format by ID.

    :param style: Style handle.
    :param numFmtId: Number format ID.
    :return: 1 on success, 0 on failure.

Font Settings
-------------

.. c:function:: void style_set_font(StyleHandle style, const char* name, int fontSize)

    Set font name and size.

    :param style: Style handle.
    :param name: Font name.
    :param fontSize: Font size in points.

.. c:function:: const char* style_font_name(StyleHandle style)

    Get font name.

    :param style: Style handle.
    :return: Font name.

.. c:function:: int style_font_size(StyleHandle style)

    Get font size.

    :param style: Style handle.
    :return: Font size in points.

.. c:function:: void style_set_font_size(StyleHandle style, int size)

    Set font size.

    :param style: Style handle.
    :param size: Font size in points.

.. c:function:: int style_italic(StyleHandle style)

    Check if font is italic.

    :param style: Style handle.
    :return: 1 if italic, 0 otherwise.

.. c:function:: void style_set_italic(StyleHandle style, int italic)

    Set italic font style.

    :param style: Style handle.
    :param italic: 1 for italic, 0 for normal.

.. c:function:: int style_strikeout(StyleHandle style)

    Check if font has strikeout.

    :param style: Style handle.
    :return: 1 if strikeout, 0 otherwise.

.. c:function:: void style_set_strikeout(StyleHandle style, int strikeOut)

    Set strikeout font style.

    :param style: Style handle.
    :param strikeOut: 1 for strikeout, 0 for normal.

.. c:function:: COLORREF style_font_color(StyleHandle style)

    Get font color.

    :param style: Style handle.
    :return: Font color as COLORREF.

.. c:function:: void style_set_font_color(StyleHandle style, COLORREF color)

    Set font color.

    :param style: Style handle.
    :param color: Font color as COLORREF.

.. c:function:: int style_bold(StyleHandle style)

    Check if font is bold.

    :param style: Style handle.
    :return: 1 if bold, 0 otherwise.

.. c:function:: void style_set_bold(StyleHandle style, int bold)

    Set bold font style.

    :param style: Style handle.
    :param bold: 1 for bold, 0 for normal.

.. c:function:: int style_font_vert_align(StyleHandle style)

    Get font vertical alignment.

    :param style: Style handle.
    :return: Vertical alignment (see :cpp:enum:`VertAlignRunEnum`).

.. c:function:: void style_set_font_vert_align(StyleHandle style, int v_alignRun)

    Set font vertical alignment.

    :param style: Style handle.
    :param v_alignRun: Vertical alignment (see :cpp:enum:`VertAlignRunEnum`).

.. c:function:: int style_underlined(StyleHandle style)

    Check if font is underlined.

    :param style: Style handle.
    :return: 1 if underlined, 0 otherwise.

.. c:function:: void style_set_underline(StyleHandle style, int underline)

    Set underline style.

    :param style: Style handle.
    :param underline: Underline style (see :cpp:enum:`UnderlineEnum`).

Border Settings
---------------

.. c:function:: int style_border(StyleHandle style, int index)

    Get border style for specific border.

    :param style: Style handle.
    :param index: Border index (see :cpp:enum:`BorderIndexEnum`).
    :return: Border style (see :cpp:enum:`BorderStyleEnum`).

.. c:function:: int style_set_border(StyleHandle style, int index, int bs)

    Set border style for specific border.

    :param style: Style handle.
    :param index: Border index (see :cpp:enum:`BorderIndexEnum`).
    :param bs: Border style (see :cpp:enum:`BorderStyleEnum`).
    :return: 1 on success, 0 on failure.

.. c:function:: COLORREF style_border_color(StyleHandle style, int index)

    Get border color for specific border.

    :param style: Style handle.
    :param index: Border index (see :cpp:enum:`BorderIndexEnum`).
    :return: Border color as COLORREF.

.. c:function:: int style_set_border_color(StyleHandle style, int index, COLORREF color)

    Set border color for specific border.

    :param style: Style handle.
    :param index: Border index (see :cpp:enum:`BorderIndexEnum`).
    :param color: Border color as COLORREF.
    :return: 1 on success, 0 on failure.

Fill and Pattern Settings
-------------------------

.. c:function:: int style_fill_pattern(StyleHandle style)

    Get fill pattern type.

    :param style: Style handle.
    :return: Fill pattern type (see :cpp:enum:`PatternTypeEnum`).

.. c:function:: void style_set_fill_pattern(StyleHandle style, int pattern)

    Set fill pattern type.

    :param style: Style handle.
    :param pattern: Fill pattern type (see :cpp:enum:`PatternTypeEnum`).

.. c:function:: COLORREF style_pattern_fg_color(StyleHandle style)

    Get pattern foreground color.

    :param style: Style handle.
    :return: Foreground color as COLORREF.

.. c:function:: void style_set_pattern_fg_color(StyleHandle style, COLORREF color)

    Set pattern foreground color.

    :param style: Style handle.
    :param color: Foreground color as COLORREF.

.. c:function:: COLORREF style_pattern_bg_color(StyleHandle style)

    Get pattern background color.

    :param style: Style handle.
    :return: Background color as COLORREF.

.. c:function:: void style_set_pattern_bg_color(StyleHandle style, COLORREF color)

    Set pattern background color.

    :param style: Style handle.
    :param color: Background color as COLORREF.

Alignment Settings
------------------

.. c:function:: int style_align_h(StyleHandle style)

    Get horizontal alignment.

    :param style: Style handle.
    :return: Horizontal alignment (see :cpp:enum:`HAlignEnum`).

.. c:function:: void style_set_align_h(StyleHandle style, int h_alignment)

    Set horizontal alignment.

    :param style: Style handle.
    :param h_alignment: Horizontal alignment (see :cpp:enum:`HAlignEnum`).

.. c:function:: int style_align_v(StyleHandle style)

    Get vertical alignment.

    :param style: Style handle.
    :return: Vertical alignment (see :cpp:enum:`VAlignEnum`).

.. c:function:: void style_set_align_v(StyleHandle style, int v_alignment)

    Set vertical alignment.

    :param style: Style handle.
    :param v_alignment: Vertical alignment (see :cpp:enum:`VAlignEnum`).

.. c:function:: int style_wrap(StyleHandle style)

    Check if text wrapping is enabled.

    :param style: Style handle.
    :return: 1 if text wrapping enabled, 0 otherwise.

.. c:function:: void style_set_wrap(StyleHandle style, int wrap)

    Set text wrapping.

    :param style: Style handle.
    :param wrap: 1 to enable text wrapping, 0 to disable.

.. c:function:: int style_rotation(StyleHandle style)

    Get text rotation angle.

    :param style: Style handle.
    :return: Text rotation angle in degrees.

.. c:function:: void style_set_rotation(StyleHandle style, int rotation)

    Set text rotation.

    :param style: Style handle.
    :param rotation: Text rotation angle in degrees.

.. c:function:: int style_indent(StyleHandle style)

    Get indentation level.

    :param style: Style handle.
    :return: Indentation level.

.. c:function:: void style_set_indent(StyleHandle style, int indent)

    Set indentation level.

    :param style: Style handle.
    :param indent: Indentation level.

.. c:function:: int style_shrink_to_fit(StyleHandle style)

    Check if shrink to fit is enabled.

    :param style: Style handle.
    :return: 1 if shrink to fit enabled, 0 otherwise.

.. c:function:: void style_set_shrink_to_fit(StyleHandle style, int shrinkToFit)

    Set shrink to fit.

    :param style: Style handle.
    :param shrinkToFit: 1 to enable shrink to fit, 0 to disable.

Protection Settings
-------------------

.. c:function:: int style_cell_locked(StyleHandle style)

    Check if cell is locked.

    :param style: Style handle.
    :return: 1 if cell locked, 0 otherwise.

.. c:function:: void style_set_cell_locked(StyleHandle style, int locked)

    Set cell locked status.

    :param style: Style handle.
    :param locked: 1 to lock cell, 0 to unlock.

.. c:function:: int style_cell_hidden(StyleHandle style)

    Check if cell formula is hidden.

    :param style: Style handle.
    :return: 1 if formula hidden, 0 otherwise.

.. c:function:: void style_set_cell_hidden(StyleHandle style, int hidden)

    Set cell formula hidden status.

    :param style: Style handle.
    :param hidden: 1 to hide formula, 0 to show.

Style Removal
-------------

.. c:function:: void style_unapply_numfmt(StyleHandle style)

    Remove number format from style.

    :param style: Style handle.

.. c:function:: void style_unapply_font(StyleHandle style)

    Remove font settings from style.

    :param style: Style handle.

.. c:function:: void style_unapply_border(StyleHandle style)

    Remove border settings from style.

    :param style: Style handle.

.. c:function:: void style_unapply_fill(StyleHandle style)

    Remove fill settings from style.

    :param style: Style handle.

.. c:function:: void style_unapply_alignment(StyleHandle style)

    Remove alignment settings from style.

    :param style: Style handle.

.. c:function:: void style_unapply_protection(StyleHandle style)

    Remove protection settings from style.

    :param style: Style handle.

Resource Management
-------------------

.. c:function:: void style_release(StyleHandle style)

    Release style resources.

    :param style: Style handle to release.

Enumerations
------------

See :ref:`enum-api` for related enumerations used by these functions.
