Author Topic: How to automatically map data columns when uploading an Excel file after moving?  (Read 521 times)

YONGHOO KIM

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 20
    • View Profile
I'm looking to implement a feature where, after downloading PQ Grid data to an Excel file, opening that file, moving columns, and then uploading it again, the system automatically identifies the column positions and populates the data accordingly.
It seems like using the 'indx' attribute might be a solution.
Could you provide guidance on how to store and process this attribute for achieving this functionality?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
When excel file is imported in the grid, the columns in grid have the same order as in Excel file by default.

Kindly share a jsfiddle if you are facing any issues.

YONGHOO KIM

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 20
    • View Profile
Of course, I understand that you want to know if there is a way to automatically populate data into the grid columns at their new positions based on an "indx" attribute, even after rearranging the grid column order in Excel.

1. Download the grid Excel file.
2. Rearrange grid column positions on the screen.
3. Automatically populate data in the order of the changed positions when uploading the Excel file.

Is there a way to achieve this?
« Last Edit: September 05, 2023, 07:35:28 am by YONGHOO KIM »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
There is no dataIndx of columns in js workbook ( js equivalent of xlsx file ) so there is no automatic or direct way to map the column positions between grid and js workbook.

One way to do it is by matching the column titles in grid and js workbook provided the column titles are not changed in grid or Excel file after export.

Assign required indx to all cells in all rows in js workbook ( wb.sheets[0].rows[ i ].cells ) and then reorder all cells in all rows using sort method.
« Last Edit: September 06, 2023, 12:02:45 pm by paramvir »