Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Create excel worksheets #1104

Open
keithknott26 opened this issue Oct 2, 2024 · 2 comments
Open

Feature Request: Create excel worksheets #1104

keithknott26 opened this issue Oct 2, 2024 · 2 comments

Comments

@keithknott26
Copy link

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!

@alejcas
Copy link
Member

alejcas commented Oct 10, 2024

I don't have the time to include this but PR are very welcome.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@alejcas @keithknott26 and others