JavaScript có thể tạo tệp Excel không?

Tại Dixie, chúng tôi đang làm việc với dữ liệu tài chính và rất nhiều khách hàng của chúng tôi cần khả năng dễ dàng xuất và làm việc với những dữ liệu này. Công cụ thực tế để thực hiện công việc nâng cao với dữ liệu số là Excel. Điều đó sẽ dễ dàng hỗ trợ, chúng tôi nghĩ. “Hãy xây dựng xuất khẩu CSV và kỳ lân sẽ nhảy múa trên mây,” chúng tôi nói. “Không nhanh như vậy,” Excel hét lên, “bạn biết là không có tiêu chuẩn CSV chung, phải không?”

Và địa ngục tan vỡ

Tôi chắc chắn đang phóng đại quá mức ở đây, nhưng vấn đề là không chỉ có một định dạng CSV phổ biến được Excel hỗ trợ. Các phiên bản Excel khác nhau sẽ yêu cầu mã hóa khác nhau, dấu phân cách trường, định dạng số, v.v.

Chúng tôi nhận thấy rằng người dùng có thể nhập CSV vào bảng tính, chỉ định dấu phân cách, v.v. trong trình hướng dẫn. Nhưng chúng tôi luôn cố gắng làm cho phần mềm của mình hỗ trợ khách hàng, vì vậy chúng tôi muốn dữ liệu của họ chỉ cần một cú nhấp chuột

Dựa trên những nhược điểm này, chúng tôi quyết định sử dụng Excel Av. và tạo bản xuất XLSX từ ứng dụng web của chúng tôi

Thời gian thực hiện

Chúng tôi có một bộ yêu cầu rất đơn giản

XLS hoặc XLSX

Vì chúng tôi đã quyết định rằng CSV không đủ tốt nên XLS hoặc XLSX sẽ là lựa chọn phù hợp. XLSX sẽ thích hợp hơn, vì thông số kỹ thuật của nó có nguồn mở và được hỗ trợ rộng rãi

không có máy chủ

Chúng tôi đã tải xuống và hiển thị dữ liệu mà người dùng sắp tải xuống. Do đó, chúng tôi đã quyết định tránh thực hiện một yêu cầu HTTP khác và tìm cách xây dựng tệp XLSX ở phía máy khách

Kích thước gói nhỏ

Làm những việc như thế này trên máy khách có nghĩa là họ phải tải xuống nhiều mã hơn để xây dựng tệp mà họ sắp tải xuống. Mặc dù chúng tôi đang sử dụng tải theo yêu cầu thông qua chia tách mã, nhưng chúng tôi vẫn muốn giữ kích thước gói ở mức thấp

Tìm kiếm thư viện JavaScript XLSX, hoạt động trong trình duyệt dường như là một nhiệm vụ đầy thách thức. Chúng tôi đã tìm thấy một thư viện, js-xlsx, quảng cáo hỗ trợ trình duyệt, nhưng đơn giản là nó quá lớn so với nhu cầu của chúng tôi. Nó trông giống như một thư viện vững chắc, nhưng có quá nhiều tính năng hơn mức chúng tôi cần

Vì vậy, chúng tôi đã từ bỏ tìm kiếm này và quyết định nghiên cứu khả năng tự xây dựng XLSX một cách đơn giản

Nó có vẻ giống như một nhiệm vụ đơn giản. Chúng tôi đang làm việc với một công nghệ mã nguồn mở, vì vậy chúng tôi giả định rằng thông số kỹ thuật sẽ dễ tìm và dễ theo dõi. Chúng tôi nhanh chóng nhận ra rằng chúng tôi đã quá ngây thơ về vấn đề này.

XLSX không dễ để tìm thấy một thông số kỹ thuật hoàn chỉnh và dễ hiểu của

Chúng tôi đã tìm kiếm nhưng chưa bao giờ thực sự tìm thấy hướng dẫn nhanh về những điều cơ bản của cấu trúc tài liệu XLSX. Vì vậy, sau vài ngày mù mịt, chúng tôi quyết định thiết kế ngược lại cấu trúc XLSX. Khi biết rằng tệp XLSX chỉ đơn giản là một kho lưu trữ zip, chúng tôi đã giải nén tệp đó và xem xét các tệp và thư mục khác nhau

Từ quá trình phẫu thuật và thử và sai này, chúng tôi có thể kết luận tệp nào được yêu cầu để tệp XLSX hợp lệ. Nó có thể bị hạn chế chỉ trong 5 tệp

  • [Loại nội dung]. xml
  • _rels/. quan hệ
  • xl/_rels/sổ làm việc. xml. quan hệ
  • xl/sổ làm việc. xml
  • xl/trang tính/trang tính1. xml

Bạn sẽ không bao giờ tin những gì xảy ra tiếp theo. Chúng tôi đã tìm thấy tài liệu thực tế về cấu trúc XML. Đó là sự thật, nó ở ngay đây. … Microsoft biết tài liệu, họ có tài liệu tốt nhất. Đúng

Tại sao tôi viết tất cả những điều này?

Chà, chúng tôi nghĩ rằng chúng tôi không thể là những người duy nhất muốn có một cách đơn giản để xuất dữ liệu từ JavaScript sang Excel. Vì vậy, chúng tôi xây dựng một thư viện nhỏ và mã nguồn mở cho nó. Chúng tôi đặt tên nó là zipcelx

Nó nhẹ (7kb) và đơn giản

Nó có một API. generateAndDownloadXlsx(config) trong đó config là một đối tượng như thế này

{
filename: 'general-ledger-Q1',
sheet: {
data: [
[{
value: 'Income - Webshop',
type: 'string'
}, {
value: 1000,
type: 'number'
}]
]
}
}

Dữ liệu trang tính về cơ bản là một ma trận biểu thị các ô trong bảng tính;

Chúng tôi hiện hỗ trợ hai loại dữ liệu. chuỗi và số. Chúng là những yếu tố cần thiết cho bảng tính

Đóng nhận xét

Chúng tôi xây dựng điều này khá nhanh chóng, nhưng chúng tôi khá tự tin với nó. Nhưng đừng ngại để lại bất kỳ đề xuất, nhận xét hoặc câu hỏi nào trong vấn đề GitHub

Để viết một tệp

import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  fileName: 'file.xlsx'
})
6, người ta phải cung cấp
const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
0 — một mảng các hàng. Mỗi hàng phải là một mảng ô

Mỗi ô phải có một

const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
1, một
const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
2 và, tùy ý, khác

Nếu một ô không có

const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
2, thì nó sẽ tự động được phát hiện từ
const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
1 hoặc mặc định là
const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
5

Một ô trống có thể được đại diện bởi

const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
6 hoặc
const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
7

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]

API

trình duyệt

import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  fileName: 'file.xlsx'
})

Sử dụng

const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
8 để lưu tệp
import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  fileName: 'file.xlsx'
})
6 từ trình duyệt web

Nếu tham số

const buffer = await writeXlsxFile(data, { buffer: true })
0 không được truyền thì giá trị trả về _______14_______1 sẽ phân giải thành "đốm màu" với nội dung của tệp ____1_______6

Nút. js

const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})

Nếu tham số

const buffer = await writeXlsxFile(data, { buffer: true })
3 không được truyền, nhưng tham số
const buffer = await writeXlsxFile(data, { buffer: true })
4 được truyền, thì nó trả về một giá trị
const buffer = await writeXlsxFile(data, { buffer: true })
5

const buffer = await writeXlsxFile(data, { buffer: true })

Nếu cả tham số

const buffer = await writeXlsxFile(data, { buffer: true })
3 và tham số
const buffer = await writeXlsxFile(data, { buffer: true })
4 đều không được truyền, thì nó sẽ trả về một giá trị có thể đọc được là
const buffer = await writeXlsxFile(data, { buffer: true })
8

const output = fs.createWriteStream(...)
const stream = await writeXlsxFile(data)
stream.pipe(output)

AWS S3 có thể từ chối chấp nhận
const buffer = await writeXlsxFile(data, { buffer: true })
9

AWS S3 có thể ném

const output = fs.createWriteStream(...)
const stream = await writeXlsxFile(data)
stream.pipe(output)
0

await new AWS.S3().putObject({
  Bucket: ...,
  Key: ...,
  Body: stream,
  ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
}).promise()

Lý do là AWS S3 chỉ chấp nhận các luồng có độ dài đã biết và không thể biết trước độ dài của tệp zip

Giải pháp thay thế cho AWS SDK v2. viết thư cho

const buffer = await writeXlsxFile(data, { buffer: true })
5 thay vì một luồng

Giải pháp thay thế cho AWS SDK v3. thao tác sử dụng

Lược đồ

Ngoài ra, thay vì cung cấp

const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
0, người ta có thể cung cấp danh sách
const output = fs.createWriteStream(...)
const stream = await writeXlsxFile(data)
stream.pipe(output)
4 và
const output = fs.createWriteStream(...)
const stream = await writeXlsxFile(data)
stream.pipe(output)
5 mô tả từng cột

const objects = [
  {
    name: 'John Smith',
    dateOfBirth: new Date(),
    cost: 1800,
    paid: true
  },
  {
    name: 'Alice Brown',
    dateOfBirth: new Date(),
    cost: 2600,
    paid: false
  }
]

const schema = [
  {
    column: 'Name',
    type: String,
    value: student => student.name
  },
  {
    column: 'Date of Birth',
    type: Date,
    format: 'mm/dd/yyyy',
    value: student => student.dateOfBirth
  },
  {
    column: 'Cost',
    type: Number,
    format: '#,##0.00',
    value: student => student.cost
  },
  {
    column: 'Paid',
    type: Boolean,
    value: student => student.paid
  }
]

Khi sử dụng

const output = fs.createWriteStream(...)
const stream = await writeXlsxFile(data)
stream.pipe(output)
5, bắt buộc phải có cột ____2_______2 (không được tự động phát hiện)

API lược đồ

trình duyệt

import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(objects, {
  schema,
  fileName: 'file.xlsx'
})

Nút. js

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
0

Thông số ô

Ngoài việc có một

const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
2 và một
const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
1, mỗi ô (hoặc cột lược đồ) cũng có thể có

  • await new AWS.S3().putObject({
      Bucket: ...,
      Key: ...,
      Body: stream,
      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }).promise()
    0 — Căn ngang nội dung ô. giá trị có sẵn.
    await new AWS.S3().putObject({
      Bucket: ...,
      Key: ...,
      Body: stream,
      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }).promise()
    1,
    await new AWS.S3().putObject({
      Bucket: ...,
      Key: ...,
      Body: stream,
      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }).promise()
    2,
    await new AWS.S3().putObject({
      Bucket: ...,
      Key: ...,
      Body: stream,
      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }).promise()
    3

  • await new AWS.S3().putObject({
      Bucket: ...,
      Key: ...,
      Body: stream,
      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }).promise()
    4 — Căn dọc nội dung ô. giá trị có sẵn.
    await new AWS.S3().putObject({
      Bucket: ...,
      Key: ...,
      Body: stream,
      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }).promise()
    5,
    await new AWS.S3().putObject({
      Bucket: ...,
      Key: ...,
      Body: stream,
      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }).promise()
    2,
    await new AWS.S3().putObject({
      Bucket: ...,
      Key: ...,
      Body: stream,
      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }).promise()
    7

  • await new AWS.S3().putObject({
      Bucket: ...,
      Key: ...,
      Body: stream,
      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }).promise()
    8 — Chiều cao hàng, tính bằng "điểm"

  • await new AWS.S3().putObject({
      Bucket: ...,
      Key: ...,
      Body: stream,
      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }).promise()
    9 — Nhịp cột. Ngay cả khi một ô trải rộng trên
    const objects = [
      {
        name: 'John Smith',
        dateOfBirth: new Date(),
        cost: 1800,
        paid: true
      },
      {
        name: 'Alice Brown',
        dateOfBirth: new Date(),
        cost: 2600,
        paid: false
      }
    ]
    0 cột, nó vẫn phải được biểu diễn dưới dạng
    const objects = [
      {
        name: 'John Smith',
        dateOfBirth: new Date(),
        cost: 1800,
        paid: true
      },
      {
        name: 'Alice Brown',
        dateOfBirth: new Date(),
        cost: 2600,
        paid: false
      }
    ]
    0 ô riêng lẻ trong
    const writeXlsxFile = require('write-excel-file/node')
    
    await writeXlsxFile(data, {
      columns, // (optional) column widths, etc.
      filePath: '/path/to/file.xlsx'
    })
    0. Trong trường hợp đó, tất cả các ô ngoại trừ ô ngoài cùng bên trái sẽ bị bỏ qua. Người ta có thể sử dụng
    const writeXlsxFile = require('write-excel-file/node')
    
    await writeXlsxFile(data, {
      columns, // (optional) column widths, etc.
      filePath: '/path/to/file.xlsx'
    })
    6 hoặc
    const writeXlsxFile = require('write-excel-file/node')
    
    await writeXlsxFile(data, {
      columns, // (optional) column widths, etc.
      filePath: '/path/to/file.xlsx'
    })
    7 để đại diện cho các ô bị bỏ qua như vậy. Ví dụ: nếu ô đầu tiên trong một hàng kéo dài 3 cột, thì hàng đó sẽ có dạng như
    const objects = [
      {
        name: 'John Smith',
        dateOfBirth: new Date(),
        cost: 1800,
        paid: true
      },
      {
        name: 'Alice Brown',
        dateOfBirth: new Date(),
        cost: 2600,
        paid: false
      }
    ]
    5

  • const objects = [
      {
        name: 'John Smith',
        dateOfBirth: new Date(),
        cost: 1800,
        paid: true
      },
      {
        name: 'Alice Brown',
        dateOfBirth: new Date(),
        cost: 2600,
        paid: false
      }
    ]
    6 — Khoảng cách hàng. Ngay cả khi một ô kéo dài ________ 33_______0 hàng, nó vẫn phải được biểu diễn dưới dạng _______ 33 _______ 0 ô riêng lẻ trong
    const writeXlsxFile = require('write-excel-file/node')
    
    await writeXlsxFile(data, {
      columns, // (optional) column widths, etc.
      filePath: '/path/to/file.xlsx'
    })
    0. Trong trường hợp đó, tất cả các ô ngoại trừ ô trên cùng sẽ bị bỏ qua. Người ta có thể sử dụng
    const writeXlsxFile = require('write-excel-file/node')
    
    await writeXlsxFile(data, {
      columns, // (optional) column widths, etc.
      filePath: '/path/to/file.xlsx'
    })
    6 hoặc
    const writeXlsxFile = require('write-excel-file/node')
    
    await writeXlsxFile(data, {
      columns, // (optional) column widths, etc.
      filePath: '/path/to/file.xlsx'
    })
    7 để đại diện cho các ô bị bỏ qua như vậy. Ví dụ: nếu ô trên cùng bên trái kéo dài 2 hàng, thì hàng đầu tiên sẽ trông giống như
    const schema = [
      {
        column: 'Name',
        type: String,
        value: student => student.name
      },
      {
        column: 'Date of Birth',
        type: Date,
        format: 'mm/dd/yyyy',
        value: student => student.dateOfBirth
      },
      {
        column: 'Cost',
        type: Number,
        format: '#,##0.00',
        value: student => student.cost
      },
      {
        column: 'Paid',
        type: Boolean,
        value: student => student.paid
      }
    ]
    2 và hàng thứ hai sẽ trông giống như
    const schema = [
      {
        column: 'Name',
        type: String,
        value: student => student.name
      },
      {
        column: 'Date of Birth',
        type: Date,
        format: 'mm/dd/yyyy',
        value: student => student.dateOfBirth
      },
      {
        column: 'Cost',
        type: Number,
        format: '#,##0.00',
        value: student => student.cost
      },
      {
        column: 'Paid',
        type: Boolean,
        value: student => student.paid
      }
    ]
    3

  • const schema = [
      {
        column: 'Name',
        type: String,
        value: student => student.name
      },
      {
        column: 'Date of Birth',
        type: Date,
        format: 'mm/dd/yyyy',
        value: student => student.dateOfBirth
      },
      {
        column: 'Cost',
        type: Number,
        format: '#,##0.00',
        value: student => student.cost
      },
      {
        column: 'Paid',
        type: Boolean,
        value: student => student.paid
      }
    ]
    4 — Đặt thành
    const schema = [
      {
        column: 'Name',
        type: String,
        value: student => student.name
      },
      {
        column: 'Date of Birth',
        type: Date,
        format: 'mm/dd/yyyy',
        value: student => student.dateOfBirth
      },
      {
        column: 'Cost',
        type: Number,
        format: '#,##0.00',
        value: student => student.cost
      },
      {
        column: 'Paid',
        type: Boolean,
        value: student => student.paid
      }
    ]
    5 để "ngăn" văn bản khi nó tràn ô

  • const schema = [
      {
        column: 'Name',
        type: String,
        value: student => student.name
      },
      {
        column: 'Date of Birth',
        type: Date,
        format: 'mm/dd/yyyy',
        value: student => student.dateOfBirth
      },
      {
        column: 'Cost',
        type: Number,
        format: '#,##0.00',
        value: student => student.cost
      },
      {
        column: 'Paid',
        type: Boolean,
        value: student => student.paid
      }
    ]
    6 — Có thể được sử dụng để in văn bản trong một họ phông chữ tùy chỉnh. Thí dụ.
    const schema = [
      {
        column: 'Name',
        type: String,
        value: student => student.name
      },
      {
        column: 'Date of Birth',
        type: Date,
        format: 'mm/dd/yyyy',
        value: student => student.dateOfBirth
      },
      {
        column: 'Cost',
        type: Number,
        format: '#,##0.00',
        value: student => student.cost
      },
      {
        column: 'Paid',
        type: Boolean,
        value: student => student.paid
      }
    ]
    7

  • const schema = [
      {
        column: 'Name',
        type: String,
        value: student => student.name
      },
      {
        column: 'Date of Birth',
        type: Date,
        format: 'mm/dd/yyyy',
        value: student => student.dateOfBirth
      },
      {
        column: 'Cost',
        type: Number,
        format: '#,##0.00',
        value: student => student.cost
      },
      {
        column: 'Paid',
        type: Boolean,
        value: student => student.paid
      }
    ]
    8 — Có thể được sử dụng để in văn bản ở cỡ chữ tùy chỉnh. Thí dụ.
    const schema = [
      {
        column: 'Name',
        type: String,
        value: student => student.name
      },
      {
        column: 'Date of Birth',
        type: Date,
        format: 'mm/dd/yyyy',
        value: student => student.dateOfBirth
      },
      {
        column: 'Cost',
        type: Number,
        format: '#,##0.00',
        value: student => student.cost
      },
      {
        column: 'Paid',
        type: Boolean,
        value: student => student.paid
      }
    ]
    9

  • import writeXlsxFile from 'write-excel-file'
    
    await writeXlsxFile(objects, {
      schema,
      fileName: 'file.xlsx'
    })
    0 — Có thể được sử dụng để in đậm văn bản. giá trị có sẵn.
    import writeXlsxFile from 'write-excel-file'
    
    await writeXlsxFile(objects, {
      schema,
      fileName: 'file.xlsx'
    })
    1

  • import writeXlsxFile from 'write-excel-file'
    
    await writeXlsxFile(objects, {
      schema,
      fileName: 'file.xlsx'
    })
    2 — Có thể được sử dụng để in nghiêng văn bản. giá trị có sẵn.
    import writeXlsxFile from 'write-excel-file'
    
    await writeXlsxFile(objects, {
      schema,
      fileName: 'file.xlsx'
    })
    3

  • ________ 37 ______ 4 — Màu văn bản của ô (ở định dạng thập lục phân). Thí dụ.

    import writeXlsxFile from 'write-excel-file'
    
    await writeXlsxFile(objects, {
      schema,
      fileName: 'file.xlsx'
    })
    5

  • ________ 37 ______ 6 — Màu nền của ô (ở định dạng thập lục phân). Thí dụ.

    import writeXlsxFile from 'write-excel-file'
    
    await writeXlsxFile(objects, {
      schema,
      fileName: 'file.xlsx'
    })
    5

  • import writeXlsxFile from 'write-excel-file'
    
    await writeXlsxFile(objects, {
      schema,
      fileName: 'file.xlsx'
    })
    8 — Màu đường viền của ô. Thí dụ.
    import writeXlsxFile from 'write-excel-file'
    
    await writeXlsxFile(objects, {
      schema,
      fileName: 'file.xlsx'
    })
    5

  • const HEADER_ROW = [
      {
        value: 'Name',
        fontWeight: 'bold'
      },
      {
        value: 'Date of Birth',
        fontWeight: 'bold'
      },
      {
        value: 'Cost',
        fontWeight: 'bold'
      },
      {
        value: 'Paid',
        fontWeight: 'bold'
      }
    ]
    
    const DATA_ROW_1 = [
      // "Name"
      {
        type: String,
        value: 'John Smith'
      },
    
      // "Date of Birth"
      {
        type: Date,
        value: new Date(),
        format: 'mm/dd/yyyy'
      },
    
      // "Cost"
      {
        type: Number,
        value: 1800
      },
    
      // "Paid"
      {
        type: Boolean,
        value: true
      }
    ]
    
    const data = [
      HEADER_ROW,
      DATA_ROW_1,
      ...
    ]
    00 — Kiểu viền ô. Thí dụ.
    const HEADER_ROW = [
      {
        value: 'Name',
        fontWeight: 'bold'
      },
      {
        value: 'Date of Birth',
        fontWeight: 'bold'
      },
      {
        value: 'Cost',
        fontWeight: 'bold'
      },
      {
        value: 'Paid',
        fontWeight: 'bold'
      }
    ]
    
    const DATA_ROW_1 = [
      // "Name"
      {
        type: String,
        value: 'John Smith'
      },
    
      // "Date of Birth"
      {
        type: Date,
        value: new Date(),
        format: 'mm/dd/yyyy'
      },
    
      // "Cost"
      {
        type: Number,
        value: 1800
      },
    
      // "Paid"
      {
        type: Boolean,
        value: true
      }
    ]
    
    const data = [
      HEADER_ROW,
      DATA_ROW_1,
      ...
    ]
    01

    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      02
    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      03
    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      04
    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      05
    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      06
    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      07
    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      08
    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      09
  • const HEADER_ROW = [
      {
        value: 'Name',
        fontWeight: 'bold'
      },
      {
        value: 'Date of Birth',
        fontWeight: 'bold'
      },
      {
        value: 'Cost',
        fontWeight: 'bold'
      },
      {
        value: 'Paid',
        fontWeight: 'bold'
      }
    ]
    
    const DATA_ROW_1 = [
      // "Name"
      {
        type: String,
        value: 'John Smith'
      },
    
      // "Date of Birth"
      {
        type: Date,
        value: new Date(),
        format: 'mm/dd/yyyy'
      },
    
      // "Cost"
      {
        type: Number,
        value: 1800
      },
    
      // "Paid"
      {
        type: Boolean,
        value: true
      }
    ]
    
    const data = [
      HEADER_ROW,
      DATA_ROW_1,
      ...
    ]
    10 — Định dạng dữ liệu di động. Chỉ có thể được sử dụng trên các ô
    const HEADER_ROW = [
      {
        value: 'Name',
        fontWeight: 'bold'
      },
      {
        value: 'Date of Birth',
        fontWeight: 'bold'
      },
      {
        value: 'Cost',
        fontWeight: 'bold'
      },
      {
        value: 'Paid',
        fontWeight: 'bold'
      }
    ]
    
    const DATA_ROW_1 = [
      // "Name"
      {
        type: String,
        value: 'John Smith'
      },
    
      // "Date of Birth"
      {
        type: Date,
        value: new Date(),
        format: 'mm/dd/yyyy'
      },
    
      // "Cost"
      {
        type: Number,
        value: 1800
      },
    
      // "Paid"
      {
        type: Boolean,
        value: true
      }
    ]
    
    const data = [
      HEADER_ROW,
      DATA_ROW_1,
      ...
    ]
    11 hoặc
    const HEADER_ROW = [
      {
        value: 'Name',
        fontWeight: 'bold'
      },
      {
        value: 'Date of Birth',
        fontWeight: 'bold'
      },
      {
        value: 'Cost',
        fontWeight: 'bold'
      },
      {
        value: 'Paid',
        fontWeight: 'bold'
      }
    ]
    
    const DATA_ROW_1 = [
      // "Name"
      {
        type: String,
        value: 'John Smith'
      },
    
      // "Date of Birth"
      {
        type: Date,
        value: new Date(),
        format: 'mm/dd/yyyy'
      },
    
      // "Cost"
      {
        type: Number,
        value: 1800
      },
    
      // "Paid"
      {
        type: Boolean,
        value: true
      }
    ]
    
    const data = [
      HEADER_ROW,
      DATA_ROW_1,
      ...
    ]
    12. Có hỗ trợ trong tiêu chuẩn
    import writeXlsxFile from 'write-excel-file'
    
    await writeXlsxFile(data, {
      columns, // (optional) column widths, etc.
      fileName: 'file.xlsx'
    })
    6. Một số cái phổ biến

    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      14 — Số dấu phẩy động có 2 chữ số thập phân. Thí dụ.
      const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      15

    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      16 — Số dấu phẩy động có 3 chữ số thập phân. Thí dụ.
      const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      17

    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      18 — Số có dấu phẩy ở phân cách hàng nghìn, như được sử dụng ở hầu hết các quốc gia nói tiếng Anh. Thí dụ.
      const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      19

    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      20 — Tiền tệ, như ở hầu hết các quốc gia nói tiếng Anh. Thí dụ.
      const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      21

    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      22 — Phần trăm. Thí dụ.
      const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      23

    • const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      24 — Phần trăm có 2 chữ số thập phân. Thí dụ.
      const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      25

    • Tất cả các ô

      const HEADER_ROW = [
        {
          value: 'Name',
          fontWeight: 'bold'
        },
        {
          value: 'Date of Birth',
          fontWeight: 'bold'
        },
        {
          value: 'Cost',
          fontWeight: 'bold'
        },
        {
          value: 'Paid',
          fontWeight: 'bold'
        }
      ]
      
      const DATA_ROW_1 = [
        // "Name"
        {
          type: String,
          value: 'John Smith'
        },
      
        // "Date of Birth"
        {
          type: Date,
          value: new Date(),
          format: 'mm/dd/yyyy'
        },
      
        // "Cost"
        {
          type: Number,
          value: 1800
        },
      
        // "Paid"
        {
          type: Boolean,
          value: true
        }
      ]
      
      const data = [
        HEADER_ROW,
        DATA_ROW_1,
        ...
      ]
      11 (hoặc cột lược đồ) yêu cầu một ____10_______27 (trừ khi được đặt)

      • const HEADER_ROW = [
          {
            value: 'Name',
            fontWeight: 'bold'
          },
          {
            value: 'Date of Birth',
            fontWeight: 'bold'
          },
          {
            value: 'Cost',
            fontWeight: 'bold'
          },
          {
            value: 'Paid',
            fontWeight: 'bold'
          }
        ]
        
        const DATA_ROW_1 = [
          // "Name"
          {
            type: String,
            value: 'John Smith'
          },
        
          // "Date of Birth"
          {
            type: Date,
            value: new Date(),
            format: 'mm/dd/yyyy'
          },
        
          // "Cost"
          {
            type: Number,
            value: 1800
          },
        
          // "Paid"
          {
            type: Boolean,
            value: true
          }
        ]
        
        const data = [
          HEADER_ROW,
          DATA_ROW_1,
          ...
        ]
        29 — Định dạng ngày tháng của Hoa Kỳ. Thí dụ.
        const HEADER_ROW = [
          {
            value: 'Name',
            fontWeight: 'bold'
          },
          {
            value: 'Date of Birth',
            fontWeight: 'bold'
          },
          {
            value: 'Cost',
            fontWeight: 'bold'
          },
          {
            value: 'Paid',
            fontWeight: 'bold'
          }
        ]
        
        const DATA_ROW_1 = [
          // "Name"
          {
            type: String,
            value: 'John Smith'
          },
        
          // "Date of Birth"
          {
            type: Date,
            value: new Date(),
            format: 'mm/dd/yyyy'
          },
        
          // "Cost"
          {
            type: Number,
            value: 1800
          },
        
          // "Paid"
          {
            type: Boolean,
            value: true
          }
        ]
        
        const data = [
          HEADER_ROW,
          DATA_ROW_1,
          ...
        ]
        30 cho ngày 31 tháng 12 năm 2000

      • const HEADER_ROW = [
          {
            value: 'Name',
            fontWeight: 'bold'
          },
          {
            value: 'Date of Birth',
            fontWeight: 'bold'
          },
          {
            value: 'Cost',
            fontWeight: 'bold'
          },
          {
            value: 'Paid',
            fontWeight: 'bold'
          }
        ]
        
        const DATA_ROW_1 = [
          // "Name"
          {
            type: String,
            value: 'John Smith'
          },
        
          // "Date of Birth"
          {
            type: Date,
            value: new Date(),
            format: 'mm/dd/yyyy'
          },
        
          // "Cost"
          {
            type: Number,
            value: 1800
          },
        
          // "Paid"
          {
            type: Boolean,
            value: true
          }
        ]
        
        const data = [
          HEADER_ROW,
          DATA_ROW_1,
          ...
        ]
        31 — Ví dụ.
        const HEADER_ROW = [
          {
            value: 'Name',
            fontWeight: 'bold'
          },
          {
            value: 'Date of Birth',
            fontWeight: 'bold'
          },
          {
            value: 'Cost',
            fontWeight: 'bold'
          },
          {
            value: 'Paid',
            fontWeight: 'bold'
          }
        ]
        
        const DATA_ROW_1 = [
          // "Name"
          {
            type: String,
            value: 'John Smith'
          },
        
          // "Date of Birth"
          {
            type: Date,
            value: new Date(),
            format: 'mm/dd/yyyy'
          },
        
          // "Cost"
          {
            type: Number,
            value: 1800
          },
        
          // "Paid"
          {
            type: Boolean,
            value: true
          }
        ]
        
        const data = [
          HEADER_ROW,
          DATA_ROW_1,
          ...
        ]
        32

      • const HEADER_ROW = [
          {
            value: 'Name',
            fontWeight: 'bold'
          },
          {
            value: 'Date of Birth',
            fontWeight: 'bold'
          },
          {
            value: 'Cost',
            fontWeight: 'bold'
          },
          {
            value: 'Paid',
            fontWeight: 'bold'
          }
        ]
        
        const DATA_ROW_1 = [
          // "Name"
          {
            type: String,
            value: 'John Smith'
          },
        
          // "Date of Birth"
          {
            type: Date,
            value: new Date(),
            format: 'mm/dd/yyyy'
          },
        
          // "Cost"
          {
            type: Number,
            value: 1800
          },
        
          // "Paid"
          {
            type: Boolean,
            value: true
          }
        ]
        
        const data = [
          HEADER_ROW,
          DATA_ROW_1,
          ...
        ]
        33 — Ví dụ.
        const HEADER_ROW = [
          {
            value: 'Name',
            fontWeight: 'bold'
          },
          {
            value: 'Date of Birth',
            fontWeight: 'bold'
          },
          {
            value: 'Cost',
            fontWeight: 'bold'
          },
          {
            value: 'Paid',
            fontWeight: 'bold'
          }
        ]
        
        const DATA_ROW_1 = [
          // "Name"
          {
            type: String,
            value: 'John Smith'
          },
        
          // "Date of Birth"
          {
            type: Date,
            value: new Date(),
            format: 'mm/dd/yyyy'
          },
        
          // "Cost"
          {
            type: Number,
            value: 1800
          },
        
          // "Paid"
          {
            type: Boolean,
            value: true
          }
        ]
        
        const data = [
          HEADER_ROW,
          DATA_ROW_1,
          ...
        ]
        34

      • const HEADER_ROW = [
          {
            value: 'Name',
            fontWeight: 'bold'
          },
          {
            value: 'Date of Birth',
            fontWeight: 'bold'
          },
          {
            value: 'Cost',
            fontWeight: 'bold'
          },
          {
            value: 'Paid',
            fontWeight: 'bold'
          }
        ]
        
        const DATA_ROW_1 = [
          // "Name"
          {
            type: String,
            value: 'John Smith'
          },
        
          // "Date of Birth"
          {
            type: Date,
            value: new Date(),
            format: 'mm/dd/yyyy'
          },
        
          // "Cost"
          {
            type: Number,
            value: 1800
          },
        
          // "Paid"
          {
            type: Boolean,
            value: true
          }
        ]
        
        const data = [
          HEADER_ROW,
          DATA_ROW_1,
          ...
        ]
        35 — Định dạng ngày giờ của Hoa Kỳ. Thí dụ.
        const HEADER_ROW = [
          {
            value: 'Name',
            fontWeight: 'bold'
          },
          {
            value: 'Date of Birth',
            fontWeight: 'bold'
          },
          {
            value: 'Cost',
            fontWeight: 'bold'
          },
          {
            value: 'Paid',
            fontWeight: 'bold'
          }
        ]
        
        const DATA_ROW_1 = [
          // "Name"
          {
            type: String,
            value: 'John Smith'
          },
        
          // "Date of Birth"
          {
            type: Date,
            value: new Date(),
            format: 'mm/dd/yyyy'
          },
        
          // "Cost"
          {
            type: Number,
            value: 1800
          },
        
          // "Paid"
          {
            type: Boolean,
            value: true
          }
        ]
        
        const data = [
          HEADER_ROW,
          DATA_ROW_1,
          ...
        ]
        36

      • hoặc bất kỳ định dạng nào khác trong đó

        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          37 — Hai chữ số cuối của số năm
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          38 — Bốn chữ số của một số năm
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          39 — Số tháng không có đầu
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          40
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          41 — Số tháng có số đứng đầu là
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          40 (khi nhỏ hơn
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          43)
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          44 — Tên tháng (viết tắt)
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          45 — Tên tháng (dài)
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          46 — Số ngày không có đầu
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          40
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          48 — Số ngày có
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          40 đứng đầu (khi nhỏ hơn
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          43)
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          51 — Số giờ không có người đứng đầu
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          40
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          53 — Số giờ dẫn đầu là
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          40 (khi ít hơn
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          43)
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          41 — Số phút có số phút dẫn đầu là
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          40 (khi nhỏ hơn
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          43)
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          59 — Giây có trước
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          40 (khi nhỏ hơn
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          43)
        • const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          62 — Hoặc là
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          63 hoặc là
          const HEADER_ROW = [
            {
              value: 'Name',
              fontWeight: 'bold'
            },
            {
              value: 'Date of Birth',
              fontWeight: 'bold'
            },
            {
              value: 'Cost',
              fontWeight: 'bold'
            },
            {
              value: 'Paid',
              fontWeight: 'bold'
            }
          ]
          
          const DATA_ROW_1 = [
            // "Name"
            {
              type: String,
              value: 'John Smith'
            },
          
            // "Date of Birth"
            {
              type: Date,
              value: new Date(),
              format: 'mm/dd/yyyy'
            },
          
            // "Cost"
            {
              type: Number,
              value: 1800
            },
          
            // "Paid"
            {
              type: Boolean,
              value: true
            }
          ]
          
          const data = [
            HEADER_ROW,
            DATA_ROW_1,
            ...
          ]
          64, tùy thuộc vào thời điểm

Tiêu đề bảng

Lược đồ

Khi sử dụng

const output = fs.createWriteStream(...)
const stream = await writeXlsxFile(data)
stream.pipe(output)
5, tiêu đề cột có thể được đặt thông qua thuộc tính
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
66 trên mỗi cột. Nó sẽ được in ở đầu bảng

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
1

Nếu thuộc tính

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
66 bị thiếu thì tiêu đề cột sẽ không được in

Kiểu tiêu đề bảng mặc định là

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
68 và
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
69 giống như kiểu cột của lược đồ
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
69. Người ta có thể cung cấp kiểu tiêu đề bảng tùy chỉnh bằng cách cung cấp tham số
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
71

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
2

Dữ liệu di động

Khi không sử dụng lược đồ, người ta có thể in tiêu đề cột bằng cách cung cấp chúng dưới dạng hàng đầu tiên của

const writeXlsxFile = require('write-excel-file/node')

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  filePath: '/path/to/file.xlsx'
})
0

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
3

Chiều rộng cột

Chiều rộng cột cũng có thể được chỉ định (bằng "ký tự")

Lược đồ

Để chỉ định chiều rộng cột khi sử dụng

const output = fs.createWriteStream(...)
const stream = await writeXlsxFile(data)
stream.pipe(output)
5, hãy đặt
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
74 trên cột giản đồ

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
4

Dữ liệu di động

Khi không sử dụng lược đồ, người ta có thể cung cấp một tham số

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
75 riêng để chỉ định độ rộng của cột

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
5

Nét chữ

Phông chữ mặc định là

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
76 tại
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
77. Để thay đổi font chữ mặc định, truyền tham số
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
78 và
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
79 khi gọi
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
80

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
6

Định hướng

Để chỉ định hướng tùy chỉnh (cho tất cả các trang tính), hãy chuyển tham số

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
81 khi gọi
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
80

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
7

Định dạng ngày tháng

Để đặt định dạng ngày mặc định, hãy chuyển tham số

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
28 khi gọi
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
80

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
8

hàng dính

Để làm cho một số hàng trên cùng "dính" (Excel gọi chúng là "đóng băng"), hãy chuyển tham số

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
85 khi gọi
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
80

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
9

Cột dính

Để làm cho một số cột ở đầu "dính" (Excel gọi chúng là "đóng băng"), hãy chuyển tham số

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
87 khi gọi
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
80

import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  fileName: 'file.xlsx'
})
0

Tên trang tính

Để đặt tên trang tính mặc định, hãy chuyển tham số

const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
89 khi gọi
const HEADER_ROW = [
  {
    value: 'Name',
    fontWeight: 'bold'
  },
  {
    value: 'Date of Birth',
    fontWeight: 'bold'
  },
  {
    value: 'Cost',
    fontWeight: 'bold'
  },
  {
    value: 'Paid',
    fontWeight: 'bold'
  }
]

const DATA_ROW_1 = [
  // "Name"
  {
    type: String,
    value: 'John Smith'
  },

  // "Date of Birth"
  {
    type: Date,
    value: new Date(),
    format: 'mm/dd/yyyy'
  },

  // "Cost"
  {
    type: Number,
    value: 1800
  },

  // "Paid"
  {
    type: Boolean,
    value: true
  }
]

const data = [
  HEADER_ROW,
  DATA_ROW_1,
  ...
]
80

import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  fileName: 'file.xlsx'
})
1

Nhiều trang tính

Lược đồ

Để tạo tệp

import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  fileName: 'file.xlsx'
})
6 có nhiều trang tính

  • Truyền tham số
    const HEADER_ROW = [
      {
        value: 'Name',
        fontWeight: 'bold'
      },
      {
        value: 'Date of Birth',
        fontWeight: 'bold'
      },
      {
        value: 'Cost',
        fontWeight: 'bold'
      },
      {
        value: 'Paid',
        fontWeight: 'bold'
      }
    ]
    
    const DATA_ROW_1 = [
      // "Name"
      {
        type: String,
        value: 'John Smith'
      },
    
      // "Date of Birth"
      {
        type: Date,
        value: new Date(),
        format: 'mm/dd/yyyy'
      },
    
      // "Cost"
      {
        type: Number,
        value: 1800
      },
    
      // "Paid"
      {
        type: Boolean,
        value: true
      }
    ]
    
    const data = [
      HEADER_ROW,
      DATA_ROW_1,
      ...
    ]
    92 — một mảng tên trang tính
  • Đối số
    const output = fs.createWriteStream(...)
    const stream = await writeXlsxFile(data)
    stream.pipe(output)
    4 phải là một mảng của
    const output = fs.createWriteStream(...)
    const stream = await writeXlsxFile(data)
    stream.pipe(output)
    4 cho mỗi trang tính
  • Tham số
    const output = fs.createWriteStream(...)
    const stream = await writeXlsxFile(data)
    stream.pipe(output)
    5 phải là một mảng gồm
    const output = fs.createWriteStream(...)
    const stream = await writeXlsxFile(data)
    stream.pipe(output)
    5 giây cho mỗi trang tính

import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  fileName: 'file.xlsx'
})
2

Dữ liệu di động

Để tạo tệp

import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  fileName: 'file.xlsx'
})
6 có nhiều trang tính

  • Truyền tham số
    const HEADER_ROW = [
      {
        value: 'Name',
        fontWeight: 'bold'
      },
      {
        value: 'Date of Birth',
        fontWeight: 'bold'
      },
      {
        value: 'Cost',
        fontWeight: 'bold'
      },
      {
        value: 'Paid',
        fontWeight: 'bold'
      }
    ]
    
    const DATA_ROW_1 = [
      // "Name"
      {
        type: String,
        value: 'John Smith'
      },
    
      // "Date of Birth"
      {
        type: Date,
        value: new Date(),
        format: 'mm/dd/yyyy'
      },
    
      // "Cost"
      {
        type: Number,
        value: 1800
      },
    
      // "Paid"
      {
        type: Boolean,
        value: true
      }
    ]
    
    const data = [
      HEADER_ROW,
      DATA_ROW_1,
      ...
    ]
    92 — một mảng tên trang tính
  • Đối số
    const writeXlsxFile = require('write-excel-file/node')
    
    await writeXlsxFile(data, {
      columns, // (optional) column widths, etc.
      filePath: '/path/to/file.xlsx'
    })
    0 phải là một mảng của
    const writeXlsxFile = require('write-excel-file/node')
    
    await writeXlsxFile(data, {
      columns, // (optional) column widths, etc.
      filePath: '/path/to/file.xlsx'
    })
    0 cho mỗi trang tính
  • (tùy chọn) Tham số
    const HEADER_ROW = [
      {
        value: 'Name',
        fontWeight: 'bold'
      },
      {
        value: 'Date of Birth',
        fontWeight: 'bold'
      },
      {
        value: 'Cost',
        fontWeight: 'bold'
      },
      {
        value: 'Paid',
        fontWeight: 'bold'
      }
    ]
    
    const DATA_ROW_1 = [
      // "Name"
      {
        type: String,
        value: 'John Smith'
      },
    
      // "Date of Birth"
      {
        type: Date,
        value: new Date(),
        format: 'mm/dd/yyyy'
      },
    
      // "Cost"
      {
        type: Number,
        value: 1800
      },
    
      // "Paid"
      {
        type: Boolean,
        value: true
      }
    ]
    
    const data = [
      HEADER_ROW,
      DATA_ROW_1,
      ...
    ]
    75 phải là một mảng của
    const HEADER_ROW = [
      {
        value: 'Name',
        fontWeight: 'bold'
      },
      {
        value: 'Date of Birth',
        fontWeight: 'bold'
      },
      {
        value: 'Cost',
        fontWeight: 'bold'
      },
      {
        value: 'Paid',
        fontWeight: 'bold'
      }
    ]
    
    const DATA_ROW_1 = [
      // "Name"
      {
        type: String,
        value: 'John Smith'
      },
    
      // "Date of Birth"
      {
        type: Date,
        value: new Date(),
        format: 'mm/dd/yyyy'
      },
    
      // "Cost"
      {
        type: Number,
        value: 1800
      },
    
      // "Paid"
      {
        type: Boolean,
        value: true
      }
    ]
    
    const data = [
      HEADER_ROW,
      DATA_ROW_1,
      ...
    ]
    75 cho mỗi trang tính

import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  fileName: 'file.xlsx'
})
3

bản đánh máy

Thư viện này đi kèm với TypeScript "types". Nếu bạn tình cờ tìm thấy bất kỳ lỗi nào trong đó, hãy tạo một vấn đề

CDN

Người ta có thể sử dụng bất kỳ dịch vụ CDN npm nào, e. g. giải nén. com hoặc jsdelivr. net

import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  fileName: 'file.xlsx'
})
4

Người giới thiệu

Dự án này được lấy cảm hứng từ gói

import writeXlsxFile from 'write-excel-file'

await writeXlsxFile(data, {
  columns, // (optional) column widths, etc.
  fileName: 'file.xlsx'
})
03

GitHub

Vào ngày 9 tháng 3 năm 2020, GitHub, Inc. âm thầm cấm tài khoản của tôi (xóa tất cả các kho lưu trữ, các vấn đề và nhận xét của tôi, ngay cả trong các kho lưu trữ riêng tư của chủ nhân của tôi) mà không có bất kỳ thông báo hay lời giải thích nào. Do đó, tất cả các mã nguồn phải được chuyển ngay sang GitLab. Repo GitHub hiện chỉ được sử dụng làm bản sao lưu (bạn cũng có thể gắn dấu sao cho repo ở đó) và repo chính hiện là GitLab. Các vấn đề có thể được báo cáo trong bất kỳ repo nào

JavaScript có thể được sử dụng cho Excel không?

API JavaScript của Excel có thể tạo và thao tác cấu trúc dữ liệu cũng như trực quan hóa trong Excel . Bảng và biểu đồ là hai trong số các đối tượng được sử dụng phổ biến hơn nhưng API hỗ trợ PivotTable, hình dạng, hình ảnh, v.v.

Làm cách nào để tạo và tải xuống Excel trong JavaScript?

hàm DownloadFile(fileName) {
// Đặt URL tệp
var url = "Tệp/" + tên tệp;
//Tạo XMLHTTPRequest
var req = new XMLHttpRequest();

Làm cách nào để tạo tệp Excel bằng nút js?

Cách tạo Bảng tính Excel từ Nút của bạn. .
Bắt đầu với SpreadJS và Node. js
Sử dụng gói npm SpreadJS
Tải tệp Excel vào nút của bạn. ứng dụng js
Thu thập đầu vào của người dùng
Điền vào tệp Excel của bạn
Xuất nút. js ra Excel

Làm cách nào để tạo tệp Excel trong TypeScript?

Tạo trang tính . nhập Excel từ 'exceljs'; . Sổ làm việc(); . addWorksheet('Danh sách các quốc gia');