Convert two-dimensional array to Excel
📥 Conversion settings
💡 Instructions for use
- Arrays of objects (one object per row) are best for export: field names automatically become table headers, and fields are ordered by first occurrence in each row.
- The two-dimensional array (one array per row) is spread out in the original order, and the first row is usually used as the field name row; select "No" to not write the field name row.
- When some rows have fewer fields than other rows, the missing positions are filled with blanks or zeros according to the "How to handle missing fields" setting to avoid misalignment of the entire column.
- It is recommended to preview before exporting: the preview and exported files use the same data. If the preview is correct, the file content will be consistent.
- Excel is downloaded in xlsx format and can be opened directly with spreadsheet software; CSV is suitable for importing into a database or script processing.
- The pasted content is only parsed and generated in the browser, and is not uploaded or saved; you need to paste it again after refreshing the page.
Convert a two-dimensional array to Excel and spread the data by element position: it can be listed correctly even without field names.
How to determine the meaning of a column when there is no field name
The two-dimensional array only records the position of the elements, not the meaning: the first element falls in the first column, the second element falls in the second column. Therefore, the meaning of the column depends entirely on the convention when the data was generated. A common practice is to use the first row as the field name row and select retain during conversion, so that the table can be read directly. If the first row itself is data, choose not to retain the field name row to avoid it being mistaken for a table header.
What to do if the lengths are uneven
- When the number of elements in each row is different, the number of columns is determined based on the longest row.
- Shorter rows are padded at the end without causing misalignment of the middle columns.
- When there is a need for zero padding, the missing processing method can be switched so that the empty positions are displayed as zero.
Object array is the most common and standardized structure. When converting to a table, it has one record per row and clear semantics. If there are arrays nested within the array, you need to decide whether to expand it into multiple lines or spell it into a piece of text before exporting.
Expanding the nested array into multiple lines will increase the number of records, and the fields of the main record will be repeated; spelling it into text will keep one line per line, but it is not conducive to statistics. Which one you choose depends on the subsequent use and there is no universal answer.
When the array is empty, the exported table only has the header. This is normal and there is no need to worry.
First confirm whether the first row is a field name or data, and then decide whether to retain the field name row.
📖 Glossary
- JSON
- A universal data exchange format that uses curly brackets to represent objects and square brackets to represent arrays. It is commonly used in front-end and various interfaces.
- object array
- It is shaped like an array with one object in each row. The key of the object is the field name. It is most suitable to be directly converted into a table.
- two-dimensional array
- Each element is also an array of arrays. The position of the element determines which column it falls in. You need to manually confirm the meaning of the column.
- Field name row
- The first row of the table is used to describe the meaning of each column. The field names of the object array will automatically become this row.
- worksheet
- A table in an Excel file. One file can contain multiple sheets. This tool exports one sheet at a time.
- xlsx
- The current Excel file format supports multiple worksheets, styles and data types, and is compatible with mainstream spreadsheet software.
- CSV
- Comma-separated plain text table format, small in size and easy to be processed by scripts, but does not retain styles and types.
- key order
- The order in which the fields are arranged from left to right in the table is determined by this tool based on the first occurrence in each row.
- Nested objects
- When an object or a multi-layered array is embedded in an object, the entire content will be written into the cell as text during export.
- Missing fields
- For fields that are not found in some rows, leave them blank or fill them with zeros when exporting to avoid misalignment of the entire row.
🔗 All keywords and tutorials
❓ FAQ
- What happens if there are numbers and text mixed in the array??
- Write as original value, numbers keep numeric type, text keep text type, no uniform format is forced.
- Can column names be automatically inferred??
- No. The array does not contain column name information, and the first row needs to be manually added in the data source.