Customize Excel file

Hello,
Is it possible to customize an Excel file, such as adding colors and inserting empty rows ?

Hey @Inno_IA

The native n8n Excel node doesn’t support formatting like colors or empty rows.

If your instance is self hosted, use exceljs in a Code node, if n8n cloud, your best option is the Microsoft Excel 365 node combined with HTTP request nodes hitting the Microsoft Graph API.

Tell me if one of these makes more sense to you and which setup you using.

Unfortunately n8n’s built-in spreadsheet nodes don’t support any formatting at all, they just handle raw data. If you’re self-hosting you could use ExcelJS in a Code node to do colors and empty rows programmatically, but honestly the easiest route is to make a pre-formatted Excel template and just write your data into it using the Microsoft Excel 365 node so the formatting stays intact.

To add to what’s been said — if you want a concrete ExcelJS approach for self-hosted, here’s the pattern that works well in a Code node:

const ExcelJS = require('exceljs');
const workbook = new ExcelJS.Workbook();
const sheet = workbook.addWorksheet('Sheet1');

// Add headers with styling
const headerRow = sheet.addRow(['Name', 'Status', 'Date']);
headerRow.eachCell(cell => {
  cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF4472C4' } };
  cell.font = { color: { argb: 'FFFFFFFF' }, bold: true };
});

// Add data rows
for (const item of $input.all()) {
  sheet.addRow([item.json.name, item.json.status, item.json.date]);
}

// Insert an empty row for visual separation
sheet.insertRow(2, []);

// Write to buffer and return as binary
const buffer = await workbook.xlsx.writeBuffer();
return [{ binary: { data: buffer.toString('base64'), mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', fileName: 'output.xlsx' } }];

One thing to note: you’ll need to enable “Allow External NPM Modules” in n8n’s settings and make sure exceljs is installed on your instance (npm install exceljs in your n8n directory). If you’re on n8n Cloud, the Microsoft Graph API route is the only real option, but the HTTP Request approach to the Graph API is actually pretty clean once you have the auth set up — you can style cells, add borders, everything.