.. _document-api:

Document Interface
==================

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

Classes
-------

.. cpp:class:: oo::iDocument

   Main document interface for creating and managing Excel workbooks.

   .. cpp:function:: oo::iWorkbook* get_workbook()

      Get the workbook associated with this document.

      :returns: Pointer to the workbook interface

   .. cpp:function:: bool save(const char* filename = nullptr)

      Save the document to a file.

      :param filename: Path to save the document. If null, saves to current file.
      :returns: true if successful, false otherwise

   .. cpp:function:: 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
----------------

.. cpp:function:: oo::iDocument* create_document()

   Create a new empty document.

   :returns: Pointer to newly created document

.. cpp:function:: oo::iDocument* load_document(const char* filename)

   Load an existing document from file.

   :param filename: Path to the Excel file to load
   :returns: Pointer to loaded document, or nullptr if failed

.. cpp:function:: const char* lib_version()

   Get the library version string.

   :returns: Constant string containing library version information

Usage Example
-------------

.. code-block:: cpp

   #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();
   }
