Skip to content

Conversation

HergenD
Copy link

@HergenD HergenD commented Nov 28, 2024

Problem:

The extension currently lacks the ability to define named ranges or formulas within an Excel workbook. Named ranges are essential for improving the readability and manageability of complex spreadsheets, allowing users to reference cells or formulas by a meaningful name.

Solution:

This pull request introduces the addDefinedName method to the Excel class. This method allows users to define named ranges or formulas within the workbook by utilizing the workbook_define_name function from the underlying libxlsxwriter library.

Changes Made:

  • Added addDefinedName Method:
    • Implemented addDefinedName in excel.c, accepting two parameters: name (the defined name) and formula (the cell or formula reference).
    • Integrated proper memory management to handle string duplication and prevent memory leaks.
  • Updated Method Entries:
    • Added the new method to the xls_methods[] array to make it accessible in the PHP extension.
  • Added Test Case:
    • Created add_defined_name.phpt to test the new functionality and ensure it works as expected.
    • The test verifies that a defined name can be added without errors and the generated Excel file is correctly created.

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

Successfully merging this pull request may close these issues.

1 participant