Workbook API Reference — oosxl 0.1.0 documentation

# Workbook API Reference

## Overview

The Workbook API provides functions to manage Excel workbooks, including date system settings, calculation modes, worksheet management, named styles, and defined names.

## Workbook Properties

int wb_is_date1904(WorkbookHandle book)

  Check if the workbook uses the 1904 date system.

  Parameters:

    - book – Handle to the workbook instance.

  Returns:

    1 if using 1904 date system, 0 otherwise.

void wb_set_date1904(WorkbookHandle book, int set)

  Set the workbook to use 1904 date system.

  Parameters:

    - book – Handle to the workbook instance.

    - set – 1 to enable 1904 date system, 0 to disable.

int wb_is_a1_ref_mode(WorkbookHandle book)

  Check if the workbook uses A1 reference style.

  Parameters:

    - book – Handle to the workbook instance.

  Returns:

    1 if using A1 reference style, 0 otherwise.

void wb_set_a1_ref_mode(WorkbookHandle book, int mode)

  Set the workbook reference style.

  Parameters:

    - book – Handle to the workbook instance.

    - mode – 1 for A1 reference style, 0 for R1C1 style.

int wb_get_calc_mode(WorkbookHandle book)

  Get the calculation mode.

  Parameters:

    - book – Handle to the workbook instance.

  Returns:

    Calculation mode (see `CalcTypeEnum`).

void wb_set_calc_mode(WorkbookHandle book, int type)

  Set the calculation mode.

  Parameters:

    - book – Handle to the workbook instance.

    - type – Calculation type (see `CalcTypeEnum`).

## Worksheet Management

WorksheetHandle wb_add_worksheet(WorkbookHandle book, const char *name)

  Add a new worksheet to the workbook.

  Parameters:

    - book – Handle to the workbook instance.

    - name – Name of the new worksheet.

  Returns:

    Handle to the created worksheet.

WorksheetHandle wb_insert_worksheet(WorkbookHandle book, int index, const char *name)

  Insert a worksheet at specified position.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Position to insert the worksheet.

    - name – Name of the new worksheet.

  Returns:

    Handle to the created worksheet.

void wb_shift_sheet(WorkbookHandle book, int srcIndex, int dstIndex)

  Move a worksheet to a different position.

  Parameters:

    - book – Handle to the workbook instance.

    - srcIndex – Source worksheet index.

    - dstIndex – Destination worksheet index.

void wb_delete_sheet(WorkbookHandle book, int index)

  Delete a worksheet from the workbook.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Index of worksheet to delete.

int wb_sheet_count(WorkbookHandle book)

  Get the number of worksheets in the workbook.

  Parameters:

    - book – Handle to the workbook instance.

  Returns:

    Number of worksheets.

WorksheetHandle wb_get_sheet(WorkbookHandle book, int index)

  Get a worksheet by index.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Worksheet index.

  Returns:

    Handle to the worksheet.

int wb_sheet_type(WorkbookHandle book, int index)

  Get the type of a worksheet.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Worksheet index.

  Returns:

    Sheet type (see `SheetTypeEnum`).

int wb_get_sheet_state(WorkbookHandle book, int index)

  Get the visibility state of a worksheet.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Worksheet index.

  Returns:

    Sheet state (see `SheetStateEnum`).

void wb_set_sheet_state(WorkbookHandle book, int index, int state)

  Set the visibility state of a worksheet.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Worksheet index.

    - state – Sheet state (see `SheetStateEnum`).

const char *wb_sheet_name(WorkbookHandle book, int index)

  Get the name of a worksheet.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Worksheet index.

  Returns:

    Worksheet name.

void wb_rename_sheet(WorkbookHandle book, int index, const char *newname)

  Rename a worksheet.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Worksheet index.

    - newname – New name for the worksheet.

int wb_get_active_sheet(WorkbookHandle book)

  Get the index of the active worksheet.

  Parameters:

    - book – Handle to the workbook instance.

  Returns:

    Index of active worksheet.

int wb_set_active_sheet(WorkbookHandle book, int tab)

  Set the active worksheet.

  Parameters:

    - book – Handle to the workbook instance.

    - tab – Worksheet index to activate.

  Returns:

    1 on success, 0 on failure.

## Defined Names

int wb_set_defined_name(WorkbookHandle book, const char *name, const char *expr, const char *local_name)

  Set a defined name in the workbook.

  Parameters:

    - book – Handle to the workbook instance.

    - name – Name to define.

    - expr – Formula expression.

    - local_name – Local sheet name (optional).

  Returns:

    1 on success, 0 on failure.

int defined_name_num(WorkbookHandle book)

  Get number of defined names in the workbook.

  Parameters:

    - book – Handle to the workbook instance.

  Returns:

    Number of defined names.

const char *ws_get_defined_name(WorkbookHandle book, int index, int *is_local = 0)

  Get the defined name.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Index of defined names.

    - is_local – Is it a locally defined name.

  Returns:

    Defined name.

const char *ws_get_local_name(WorkbookHandle book, int index)

  Retrieve the worksheet name to which the defined name belongs.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Index of defined names.

  Returns:

    Worksheet name.

const char *ws_get_defined_name_expr(WorkbookHandle book, int index)

  Get the expression for a defined name.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Index of defined names.

  Returns:

    Expression string.

void ws_delete_defined_name(WorkbookHandle book, int index)

  Delete a defined name.

  Parameters:

    - book – Handle to the workbook instance.

    - index – Index of defined names.

## Style Management

StyleHandle wb_get_named_style(WorkbookHandle book, const char *name)

  Get a named style from the workbook.

  Parameters:

    - book – Handle to the workbook instance.

    - name – Style name(For the name of the built-in style, please refer to Built-in cell styles:).

  Returns:

    Handle to the style.

StyleHandle wb_add_custom_style(WorkbookHandle book, const char *name, StyleHandle style)

  Add a custom named style to the workbook.

  Parameters:

    - book – Handle to the workbook instance.

    - name – Name for the custom style.

    - style – Style handle to add.

  Returns:

    Handle to the added style.

int wb_modify_named_style(WorkbookHandle book, const char *name, StyleHandle style)

  Modify an existing named style.

  Parameters:

    - book – Handle to the workbook instance.

    - name – Name of the style to modify(For the name of the built-in style, please refer to Built-in cell styles:).

    - style – New style properties.

  Returns:

    1 on success, 0 on failure.

StyleHandle wb_make_normal_style(WorkbookHandle book)

  Create a normal style for the workbook.

  Parameters:

    - book – Handle to the workbook instance.

  Returns:

    Handle to the created normal style.

## Rich Text

RichtextHandle wb_make_richtext(WorkbookHandle book)

  Create a rich text object.

  Parameters:

    - book – Handle to the workbook instance.

  Returns:

    Handle to the created rich text object.

## Enumerations

See Enumerations Reference for related enumerations used by these functions.

Styled using the Piccolo Theme