ExportPlugin: Nested Headers and Preprocess Data

Tags: #<Tag:0x00007efc6557a7c0>

Hi,

I want to export data from handsontable to csv. The basics work just fine, but I am stuck with two scenarios:

  1. I have nested headers and I would like to include the last row of the header in the exported file. As I understood it, the nested header is actually a different handsontable instance, so the exportHeaders-Flag doesn’t help.
  2. In some columns I have JSON strings in the cells and custom renderers. The basic approach obviously just exports the cell data (=json string). Is there a way to preprocess the data before exporting?

Thanks for the help.

Hey @stephan.boehme

esport to .CSV uses colHeaders, not nestedHeaders. Exporting nestedHeaders is not supported yet.

Can you share and example of i/o data for the 2nd case?

any updates @stephan.boehme :slight_smile: I guess that you might have some Christmas - New Year vacation so I’m not closing this issue yet.

Since I need to export to xlsx, I changed from the export plugin to excelJS and simply use hot.getSettings().data as data to export. Then I can change certain cell values as I need, so the second case is not an issue any more.

But along the way I ran into another problem where I am stuck now. It’s a bit off topic to the original question…

Anyway: I have my source data from the handsontable and I use hidden columns and row filtering. With ExcelJS I can set hidden columns and rows. With columns it is easy, but how can I get the information whether a certain physical row index is currently filtered or not?

I tried to use toVisualRow() and test for null, but that gives sometimes unexpected results. Is there any other way?

That would sound like a good plan to me. What are the ‘unexpected results’ ?

In some situations toVisualRow() returned null although the row was not filtered and, hence, should have a visual row that isn’t null.

But I could not simply reproduce this behaviour in a small example. I use several plugins (filter, hiddenColumns, multiColumn Sorting, nestedHeaders, …). Maybe there are somewhere some strange side effects.

So is there any other way to test it?

Do you allow to change data? If not you could create an array of the cells are just compare the content, missing content = missing row. If you allow to edit data you could add an additional column with IDs and hide it.

I change the data and I already have a column with unique row ids.

If I understood you correctly, you imply using a method like getDataAtCol(i) which only shows the filtered data. Is that right? That sounds like a feasible idea. I’ll try that out later. Thanks!

Exactly! Please keep me updated.

Worked perfectly, thanks for the help!

Great :slight_smile: Thank you for confirmation.