EXCEL Writer

Create an XLSX format file. Copy the data from the specified Excel file, use the provided Low-Code API to add or modify data or styles, and generate a new Excel file named 'output.xlsx'

EXCEL

Click "PICK", enter the Excel file name from the working folder via the keyboard, or use the %FILENAME% variable to select a .xlsx format file. The loaded data will be added to the output file output.xlsx by default. If you don't need to reference any Excel file, you can leave it blank.

API

In addition to the common file handling synchronous functions like api.files(), api.read(filename, encoding='utf8'), api.write(filename, text), and api.remove(filename), there are also other synchronous functions provided such as api.addSheet(header, rows, name), api.delSheet(name), api.sheetNames(), api.mergeCells(name, startRow, startCol, endRow, endCol), api.getCell(name, row, col), api.setCell(name, row, col, value, style), api.setColWidth(name, col, width), and api.setRowHeight(name, row, height). You can refer to the following examples for usage:

// List all the sheets in the Excel file
console.log(api.sheetNames())

// Add a new sheet
let rows = [{col1: 1, col2: '2'},{col1: 3, col2: '4'}]
api.addSheet(['col2','col1'], rows, 'new sheet')

// Merge Cells from B2 to C3
api.mergeCells('new sheet', 1, 1, 1, 2)

// Get the value of a specific cell (e.g., A1)
console.log(api.getCell('new sheet', 0, 0))

// Write a value to a specific cell (e.g., B2)
api.setCell('new sheet', 1, 1, 'hello')

// Set the height of the first row (row 0) to 50
api.setRowHeight('new sheet', 0, 50)

// Set the width of column C to 0 (hide the column)
api.setColWidth('new sheet', 2, 0) 

// Delete sheet
api.delSheet('new sheet')

Set styles for a specific cell in an Excel sheet using a style object (applicable to .xlsx format files only). The format is as follows:

// Style Object
const style = {
  alignment: {
    vertical: 'bottom', // 'top', 'center'
    horizontal: 'left', // 'center', 'right'
    wrapText: false, // true
  },
  font: {
    name: 'Calibri', // font family name
    sz: 12, // font size
    color: { rgb: 'FF0000' },
    bold: false, // true
    italic: false, // true
    underline: false, // true
    strike: false, // true
  },
  fill: {
    fgColor: { rgb: '00FF00' }
  },
  border: {
    top: { 
      style: 'thin', // 'thick','dashed','dotted','hair','medium'
      color: { rgb: '000000' }
    },
    bottom: {
      style: 'thin',
      color: { rgb: '000000' }
    },
    left: {
      style: 'thin',
      color: { rgb: '000000' }
    },
    right: {
      style: 'thin',
      color: { rgb: '000000' }
    }
  }
}

// Set the style of cell A1
api.setCell('sheet name', 0, 0, 'style demo', style)

--

We are dedicated to improving our content. Please let us know if you come across any errors, including spelling, grammar, or other mistakes, as your feedback is valuable to us! 🤖️⚡️

Last updated