Export to file with hiddenColumns (Pro)

Tags: #<Tag:0x00007efc646c9d20>

Hello,

I am using Handsontable Pro to export my data as a csv file with the option exportHiddenColumns: false. It works great until hiddenColumns and manualColumnMove plugin is enabled.

If I move columns around and hide some columns then it does not export correctly. That is the csv file will show columns that are supposed to be hidden. Hopefully the below example demonstrates what I mean.

  1. Original columns: [A, B, C, D, E]
  2. After moving columns: [A, C, B, D, E]
  3. After hide column: [A, B, D, E]

After doing the above operations then exporting to file you will see the columns [A, C, D, E] in the csv. If a JSFiddle is needed to demo this then please let me know.

This is really frustrating because the ExportToFile plugin advertises that it can export to file without exporting hidden columns, but the actual functionality differs.

Thanks.

I have found a solution to my problem. It deals with changing the source code of the ExportFile plugin.

If anyone is curious, specifically the change happens in dataProvider.js. What you have to do is add a reference to the hiddenColumns plugin and modify the _isHiddenRow() function to do the following:

  1. check that hiddenColumns plugin is enabled
  2. if enabled then get the logical column index: logicalCol = hiddenColumnsPlugin.getLogicalColumnIndex(column)
  3. return the boolean: hiddenColumnsPlugin.hiddenColumns.indexOf(logicalCol) !== -1

Hope it helps someone else

Thanks for sharing your investigation results @rodriada000