When working with tables in SpreadJS, you may encounter a situation where renaming a column header to a name that already exists in another column causes SpreadJS to automatically rename the duplicate header.
For example, in the SpreadJS Table Binding demo, if the first column header Order Date is renamed to Units, while another column already has the Units header, the duplicate header is automatically changed to Units2.
Cause
This behavior is by design. SpreadJS does not support duplicate column header names in a table, similar to the behavior in Microsoft Excel.
When a column header is changed to a name that already exists in the table, SpreadJS automatically modifies the header name to maintain unique column headers. Therefore, Units is changed to Units2 when Units already exists.
Solution
Duplicate column headers are not supported in SpreadJS tables, and the automatic renaming behavior cannot be disabled to allow duplicate header names.
If your application requires custom validation or a warning when a user changes a column header, you can use SpreadJS events such as:
These events can be used to detect the change and implement custom validation or display a warning or error message in the application.
Kristina Ismail