Style API Reference — oosxl 0.1.0 documentation

# 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

int style_set_numfmt(StyleHandle style, const char *numFmtCode)

  Set custom number format code.

  Parameters:

    - style – Style handle.

    - numFmtCode – Number format code string.

  Returns:

    1 on success, 0 on failure.

const char *style_numfmt_code(StyleHandle style)

  Get number format code.

  Parameters:

    - style – Style handle.

  Returns:

    Number format code string.

int style_numfmt_id(StyleHandle style)

  Get number format ID.

  Parameters:

    - style – Style handle.

  Returns:

    Number format ID.

int style_set_numfmt_id(StyleHandle style, int numFmtId)

  Set number format by ID.

  Parameters:

    - style – Style handle.

    - numFmtId – Number format ID.

  Returns:

    1 on success, 0 on failure.

## Font Settings

void style_set_font(StyleHandle style, const char *name, int fontSize)

  Set font name and size.

  Parameters:

    - style – Style handle.

    - name – Font name.

    - fontSize – Font size in points.

const char *style_font_name(StyleHandle style)

  Get font name.

  Parameters:

    - style – Style handle.

  Returns:

    Font name.

int style_font_size(StyleHandle style)

  Get font size.

  Parameters:

    - style – Style handle.

  Returns:

    Font size in points.

void style_set_font_size(StyleHandle style, int size)

  Set font size.

  Parameters:

    - style – Style handle.

    - size – Font size in points.

int style_italic(StyleHandle style)

  Check if font is italic.

  Parameters:

    - style – Style handle.

  Returns:

    1 if italic, 0 otherwise.

void style_set_italic(StyleHandle style, int italic)

  Set italic font style.

  Parameters:

    - style – Style handle.

    - italic – 1 for italic, 0 for normal.

int style_strikeout(StyleHandle style)

  Check if font has strikeout.

  Parameters:

    - style – Style handle.

  Returns:

    1 if strikeout, 0 otherwise.

void style_set_strikeout(StyleHandle style, int strikeOut)

  Set strikeout font style.

  Parameters:

    - style – Style handle.

    - strikeOut – 1 for strikeout, 0 for normal.

COLORREF style_font_color(StyleHandle style)

  Get font color.

  Parameters:

    - style – Style handle.

  Returns:

    Font color as COLORREF.

void style_set_font_color(StyleHandle style, COLORREF color)

  Set font color.

  Parameters:

    - style – Style handle.

    - color – Font color as COLORREF.

int style_bold(StyleHandle style)

  Check if font is bold.

  Parameters:

    - style – Style handle.

  Returns:

    1 if bold, 0 otherwise.

void style_set_bold(StyleHandle style, int bold)

  Set bold font style.

  Parameters:

    - style – Style handle.

    - bold – 1 for bold, 0 for normal.

int style_font_vert_align(StyleHandle style)

  Get font vertical alignment.

  Parameters:

    - style – Style handle.

  Returns:

    Vertical alignment (see `VertAlignRunEnum`).

void style_set_font_vert_align(StyleHandle style, int v_alignRun)

  Set font vertical alignment.

  Parameters:

    - style – Style handle.

    - v_alignRun – Vertical alignment (see `VertAlignRunEnum`).

int style_underlined(StyleHandle style)

  Check if font is underlined.

  Parameters:

    - style – Style handle.

  Returns:

    1 if underlined, 0 otherwise.

void style_set_underline(StyleHandle style, int underline)

  Set underline style.

  Parameters:

    - style – Style handle.

    - underline – Underline style (see `UnderlineEnum`).

## Border Settings

int style_border(StyleHandle style, int index)

  Get border style for specific border.

  Parameters:

    - style – Style handle.

    - index – Border index (see `BorderIndexEnum`).

  Returns:

    Border style (see `BorderStyleEnum`).

int style_set_border(StyleHandle style, int index, int bs)

  Set border style for specific border.

  Parameters:

    - style – Style handle.

    - index – Border index (see `BorderIndexEnum`).

    - bs – Border style (see `BorderStyleEnum`).

  Returns:

    1 on success, 0 on failure.

COLORREF style_border_color(StyleHandle style, int index)

  Get border color for specific border.

  Parameters:

    - style – Style handle.

    - index – Border index (see `BorderIndexEnum`).

  Returns:

    Border color as COLORREF.

int style_set_border_color(StyleHandle style, int index, COLORREF color)

  Set border color for specific border.

  Parameters:

    - style – Style handle.

    - index – Border index (see `BorderIndexEnum`).

    - color – Border color as COLORREF.

  Returns:

    1 on success, 0 on failure.

## Fill and Pattern Settings

int style_fill_pattern(StyleHandle style)

  Get fill pattern type.

  Parameters:

    - style – Style handle.

  Returns:

    Fill pattern type (see `PatternTypeEnum`).

void style_set_fill_pattern(StyleHandle style, int pattern)

  Set fill pattern type.

  Parameters:

    - style – Style handle.

    - pattern – Fill pattern type (see `PatternTypeEnum`).

COLORREF style_pattern_fg_color(StyleHandle style)

  Get pattern foreground color.

  Parameters:

    - style – Style handle.

  Returns:

    Foreground color as COLORREF.

void style_set_pattern_fg_color(StyleHandle style, COLORREF color)

  Set pattern foreground color.

  Parameters:

    - style – Style handle.

    - color – Foreground color as COLORREF.

COLORREF style_pattern_bg_color(StyleHandle style)

  Get pattern background color.

  Parameters:

    - style – Style handle.

  Returns:

    Background color as COLORREF.

void style_set_pattern_bg_color(StyleHandle style, COLORREF color)

  Set pattern background color.

  Parameters:

    - style – Style handle.

    - color – Background color as COLORREF.

## Alignment Settings

int style_align_h(StyleHandle style)

  Get horizontal alignment.

  Parameters:

    - style – Style handle.

  Returns:

    Horizontal alignment (see `HAlignEnum`).

void style_set_align_h(StyleHandle style, int h_alignment)

  Set horizontal alignment.

  Parameters:

    - style – Style handle.

    - h_alignment – Horizontal alignment (see `HAlignEnum`).

int style_align_v(StyleHandle style)

  Get vertical alignment.

  Parameters:

    - style – Style handle.

  Returns:

    Vertical alignment (see `VAlignEnum`).

void style_set_align_v(StyleHandle style, int v_alignment)

  Set vertical alignment.

  Parameters:

    - style – Style handle.

    - v_alignment – Vertical alignment (see `VAlignEnum`).

int style_wrap(StyleHandle style)

  Check if text wrapping is enabled.

  Parameters:

    - style – Style handle.

  Returns:

    1 if text wrapping enabled, 0 otherwise.

void style_set_wrap(StyleHandle style, int wrap)

  Set text wrapping.

  Parameters:

    - style – Style handle.

    - wrap – 1 to enable text wrapping, 0 to disable.

int style_rotation(StyleHandle style)

  Get text rotation angle.

  Parameters:

    - style – Style handle.

  Returns:

    Text rotation angle in degrees.

void style_set_rotation(StyleHandle style, int rotation)

  Set text rotation.

  Parameters:

    - style – Style handle.

    - rotation – Text rotation angle in degrees.

int style_indent(StyleHandle style)

  Get indentation level.

  Parameters:

    - style – Style handle.

  Returns:

    Indentation level.

void style_set_indent(StyleHandle style, int indent)

  Set indentation level.

  Parameters:

    - style – Style handle.

    - indent – Indentation level.

int style_shrink_to_fit(StyleHandle style)

  Check if shrink to fit is enabled.

  Parameters:

    - style – Style handle.

  Returns:

    1 if shrink to fit enabled, 0 otherwise.

void style_set_shrink_to_fit(StyleHandle style, int shrinkToFit)

  Set shrink to fit.

  Parameters:

    - style – Style handle.

    - shrinkToFit – 1 to enable shrink to fit, 0 to disable.

## Protection Settings

int style_cell_locked(StyleHandle style)

  Check if cell is locked.

  Parameters:

    - style – Style handle.

  Returns:

    1 if cell locked, 0 otherwise.

void style_set_cell_locked(StyleHandle style, int locked)

  Set cell locked status.

  Parameters:

    - style – Style handle.

    - locked – 1 to lock cell, 0 to unlock.

int style_cell_hidden(StyleHandle style)

  Check if cell formula is hidden.

  Parameters:

    - style – Style handle.

  Returns:

    1 if formula hidden, 0 otherwise.

void style_set_cell_hidden(StyleHandle style, int hidden)

  Set cell formula hidden status.

  Parameters:

    - style – Style handle.

    - hidden – 1 to hide formula, 0 to show.

## Style Removal

void style_unapply_numfmt(StyleHandle style)

  Remove number format from style.

  Parameters:

    - style – Style handle.

void style_unapply_font(StyleHandle style)

  Remove font settings from style.

  Parameters:

    - style – Style handle.

void style_unapply_border(StyleHandle style)

  Remove border settings from style.

  Parameters:

    - style – Style handle.

void style_unapply_fill(StyleHandle style)

  Remove fill settings from style.

  Parameters:

    - style – Style handle.

void style_unapply_alignment(StyleHandle style)

  Remove alignment settings from style.

  Parameters:

    - style – Style handle.

void style_unapply_protection(StyleHandle style)

  Remove protection settings from style.

  Parameters:

    - style – Style handle.

## Resource Management

void style_release(StyleHandle style)

  Release style resources.

  Parameters:

    - style – Style handle to release.

## Enumerations

See Enumerations Reference for related enumerations used by these functions.

Styled using the Piccolo Theme