# Document Interface

The Document interface represents the main document object that manages Excel workbooks.

## Classes

class oo::iDocument

  Main document interface for creating and managing Excel workbooks.

  oo::iWorkbook *get_workbook()

    Get the workbook associated with this document.

    Returns:

      Pointer to the workbook interface

  bool save(const char *filename = nullptr) const

    Save the document to a file.

    Parameters:

      filename – Path to save the document. If null, saves to current file.

    Returns:

      true if successful, false otherwise

  bool save_to_csv(const char *filename = nullptr) const

    Save the current active worksheet to a csv file.

    Parameters:

      filename – The path and file name where the file will be saved. If NULL, the worksheet name will be used as the csv file name and the csv file will be saved in the current working directory.

    Returns:

      true if successful, false otherwise

  void release()

    Release the document and free associated resources.

    Warning

    This should be called when the document is no longer needed to prevent memory leaks.

## Global Functions

const char *lib_version()

  Get the library version string.

  Returns:

    Constant string containing library version information

void set_product_key(const char *user, const char *key)

  Set the license key.

  Parameters:

    - user – User name

    - key – License key

oo::iDocument *create_document()

  Create a new empty document.

  Returns:

    Pointer to newly created document

oo::iDocument *load_document(const char *filename)

  Load an existing document from file.

  Parameters:

    filename – Path to the Excel file to load

  Returns:

    Pointer to loaded document, or nullptr if failed

oo::iCSVPolicy *create_csv_policy()

  Create a new default csv policy.

  Returns:

    Pointer to newly created csv policy

oo::iDocument *load_csv(const char *filename, const oo::iCSVPolicy *policy)

  Load an existing document from csv file.

  Parameters:

    - filename – Path to the csv file to load

    - policy – A CSV policy for configuring the parsing rules applied to CSV files.

  Returns:

    Pointer to loaded document, or nullptr if failed

## Usage Example

    #include "oosxl.hxx"

    // Create a new document
    oo::iDocument* doc = create_document();

    if (doc) {
        // Get workbook and work with sheets
        oo::iWorkbook* workbook = doc->get_workbook();

        // Perform operations...

        // Save document
        doc->save("example.xlsx");

        // Clean up
        doc->release();
    }

Styled using the Piccolo Theme