Skip to content

Feature Request: Create excel worksheets #1104

Open
@keithknott26

Description

@keithknott26

Hi,

Firstly thank you for all your hard work on this project I use it often.

Would you kindly include the creation of excel worksheets into excel.py so we can get, create, update, and delete workbooks? Today I see it handles only get, update, and delete.

here's a modification to excel.py to handle this:
`class WorkSheet(ApiComponent):
""" An Excel WorkSheet """

_endpoints = {
    'get_tables': '/tables',
    'get_table': '/tables/{id}',
    'get_range': '/range',
    'add_table': '/tables/add',
    'get_used_range': '/usedRange(valuesOnly={})',
    'get_cell': '/cell(row={row},column={column})',
    'add_named_range': '/names/add',
    'add_named_range_f': '/names/addFormulaLocal',
    'get_named_range': '/names/{name}',
    'create_worksheet': '/worksheets'
}

# Existing constructors and methods...

def create_worksheet(self, name):
    """
    Creates a new worksheet in the workbook with the specified name.
    :param str name: The name of the new worksheet.
    :return: The newly created WorkSheet instance.
    """
    url = self.build_url(self._endpoints.get('create_worksheet'))
    data = {'name': name}
    response = self.session.post(url, json=data)
    
    if not response:
        logging.error(f"Failed to create worksheet '{name}'")
        return None
    
    return WorkSheet(parent=self.workbook, **{self._cloud_data_key: response.json()})

`

For now I'll have to work around this until it's included, appreciate your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions