Order of fields

Describe the problem/error/question

I have to generate an Excel file. To be usable, order of fields is import (not of items)
I tryed to use a Set function, but fields are randomly ordered
Is there a way to order fields?

Thanks for your help

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

@ppcm ,

I have to generate an Excel file. To be usable, order of fields is import

To populate a spreadsheet, you typically need an array of objects. According to definition of the object (aka dictionary or JSON),

An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a string, number, boolean, null, object, or array.
– RFC-7159: RFC 7159: The JavaScript Object Notation (JSON) Data Interchange Format

Perhaps you could provide more details of how you are trying to achieve that? The problem is likely in the way you are doing it.

@ihortom thanks for the answer, the problem is not the generation of the Excel file, but the order of columns

For example, here you can find a workflow with an array (column1, column3, column4) and I would to add the column2 between column1 and column3. After that, the Excel file will be generated

Any idea?

Hey @ppcm,

Try this… All I have done is told the Set node not to carry forward the input items as you are setting them in the node, This results in the correct order coming out of the node and should mean your Excel file is being created in the order you are after.

@ppcm , Jon’s solution is the easiest. However, if you have a long list of columns it could be tedious to add them manually in Set. Instead, they could be arranged automatically in alphabetical order. Below is an example how to do it.

It could be reworked to arrange the columns in a specific order as well.

1 Like

Simple like that
Thanks a lot, it works great!

This an other way, but I need a specific order not in alphabetic order…
But I keep it in mind, if needed

Thanks a lot