Author Topic: Creating Dynamic Columns while using the importXl method  (Read 445 times)

pbassey

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 36
    • View Profile
Creating Dynamic Columns while using the importXl method
« on: October 28, 2022, 12:30:14 am »
Does your grid control support the loading of data from and excel file (using the importXL method) as well as calculated columns in-between the columns/rows loaded as a result of the importXL data load?

I want to load all the data from an .xlsx file, but also insert new columns inside the loaded grid that has formulas such as "MID(N3,6,19)”.

Is this possible ??

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Creating Dynamic Columns while using the importXl method
« Reply #1 on: October 28, 2022, 07:07:48 am »
Yes

New columns can be added or inserted with grid.Columns() API

Excel functions can be added with grid.Range().value() API

Code: [Select]
        grid.Columns().add([{dataIndx:'type', title:'Type', width: 150}]);

        var values = (new Array(5).fill(0)).map(function(val, indx){
        return '=MID(A' + (indx+2) + ',16)';
        });
       
        grid.Range('B2:B6').value(values);

jsfiddle: https://jsfiddle.net/rwbteua1/

API reference:

https://paramquery.com/pro/api#method-Columns

https://paramquery.com/pro/api#method-Range