Rich Text API Reference — oosxl 0.1.0 documentation

# Rich Text API Reference

## Overview

The Rich Text API provides functions to create and manipulate rich text content in Excel cells, allowing formatted text with multiple styles within a single cell.

## Rich Text Information

int rt_segments_num(RichtextHandle rt)

  Get the number of text segments in the rich text.

  Parameters:

    - rt – Rich text handle.

  Returns:

    Number of text segments.

const char *rt_plain_text(RichtextHandle rt)

  Get the plain text content of the rich text.

  Parameters:

    - rt – Rich text handle.

  Returns:

    Plain text string.

## Text Segment Operations

const char *rt_text(RichtextHandle rt, int index, StyleHandle *style)

  Get text and style of a specific segment.

  Parameters:

    - rt – Rich text handle.

    - index – Segment index (0-based).

    - style – Pointer to store the segment’s style handle.

  Returns:

    Text content of the segment.

void rt_append(RichtextHandle rt, const char *s, StyleHandle style)

  Append a new text segment to the rich text.

  Parameters:

    - rt – Rich text handle.

    - s – Text content to append.

    - style – Style for the new segment.

void rt_insert(RichtextHandle rt, int index, const char *s, StyleHandle style)

  Insert a new text segment at specified position.

  Parameters:

    - rt – Rich text handle.

    - index – Position to insert the segment.

    - s – Text content to insert.

    - style – Style for the new segment.

void rt_remove(RichtextHandle rt, int index)

  Remove a text segment from the rich text.

  Parameters:

    - rt – Rich text handle.

    - index – Index of segment to remove.

void rt_modify(RichtextHandle rt, int index, const char *s, StyleHandle style)

  Modify an existing text segment.

  Parameters:

    - rt – Rich text handle.

    - index – Index of segment to modify.

    - s – New text content.

    - style – New style for the segment.

## Resource Management

void rt_release(RichtextHandle rt)

  Release rich text resources.

  Parameters:

    - rt – Rich text handle to release.

## Usage Example

Typical usage pattern for rich text:

    // Create rich text from workbook
    RichtextHandle rt = wb_make_richtext(workbook);

    // Append segments with different styles
    rt_append(rt, "This is ", normal_style);
    rt_append(rt, "bold", bold_style);
    rt_append(rt, " and ", normal_style);
    rt_append(rt, "italic", italic_style);
    rt_append(rt, " text.", normal_style);

    // Apply to cell
    ws_set_richtext(worksheet, 1, 1, rt);

    // Release when done
    rt_release(rt);

Styled using the Piccolo Theme