This PR introduces a new function update_xls_form that updates a custom XLS form by integrating mandatory fields at the start (calculation fields) and appending additional fields (digitization fields) at the end. The function processes all sheets within the provided Excel files, ensuring that any common fields between the custom, mandatory, and append forms are handled correctly.
Key Features:
Multiple Sheets Handling: The function iterates through all sheets in the custom form, updating them with corresponding sheets from the mandatory and append forms.
Custom Fields Preservation: The function ensures that any fields present in the custom form are preserved in their original order, with mandatory fields placed at the beginning and additional fields appended afterward.
Common Fields Management: The function identifies common fields across all three forms, retaining the custom form's version of these fields and excluding them from the mandatory and digitisation forms to prevent duplication.
Efficient Memory Usage: The function returns the updated Excel form directly as a BytesIO object without writing to a file, optimizing memory usage and improving efficiency.
Description:
This PR introduces a new function
update_xls_form
that updates a custom XLS form by integrating mandatory fields at the start (calculation fields) and appending additional fields (digitization fields) at the end. The function processes all sheets within the provided Excel files, ensuring that any common fields between the custom, mandatory, and append forms are handled correctly.Key Features:
Multiple Sheets Handling:
The function iterates through all sheets in the custom form, updating them with corresponding sheets from the mandatory and append forms.Custom Fields Preservation:
The function ensures that any fields present in the custom form are preserved in their original order, with mandatory fields placed at the beginning and additional fields appended afterward.Common Fields Management:
The function identifies common fields across all three forms, retaining the custom form's version of these fields and excluding them from the mandatory and digitisation forms to prevent duplication.Efficient Memory Usage:
The function returns the updated Excel form directly as a BytesIO object without writing to a file, optimizing memory usage and improving efficiency.