xlsxwriter.swift: A wrapper in Swift around Libxlsxwriter for creating Excel XLSX files.

import xlsxwriter

// Create a new workbook and add a worksheet.
var wb = Workbook(name: "demo.xlsx")
defer { wb.close() }
let ws = wb.addWorksheet()

// Add a format.
let format = wb.addFormat()

// Set the bold property for the format

// Write some simple text.
ws.write(.string("Hello"), [0, 0])

// Text with formatting.
ws.write(.string("World"), [0, 1], format: format)


Install Libxlswriter first. See Getting started.

Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code.

  1. Add the following to your Package.swift file:
dependencies: [
    .package(url: "https://github.com/damuellen/xlsxwriter.swift", from: "1.0.0")
  1. Build your project:


$ swift build

(Windows only)

$ swift build -Xswiftc -LC:/vcpkg/installed/x64-windows/lib/ -Xcc -IC:/vcpkg/installed/x64-windows/include/

Attention: Install the libxlsxwriter c library first, not part of the build.

The libxlsxwriter library

Libxlsxwriter is a C library that can be used to write text, numbers, formulas and hyperlinks to multiple worksheets in an Excel 2007+ XLSX file.

It supports features such as:

  • 100% compatible Excel XLSX files.
  • Full Excel formatting.
  • Merged cells.
  • Defined names.
  • Autofilters.
  • Charts.
  • Data validation and drop down lists.
  • Conditional formatting.
  • Worksheet PNG/JPEG images.
  • Cell comments.
  • Support for adding Macros.
  • Memory optimization mode for writing large files.
  • Source code available on GitHub.
  • FreeBSD license.
  • ANSI C.
  • Works with GCC, Clang, Xcode, MSVC 2015, ICC, TCC, MinGW, MingGW-w64/32.
  • Works on Linux, FreeBSD, OpenBSD, OS X, iOS and Windows. Also works on MSYS/MSYS2 and Cygwin.
  • Compiles for 32 and 64 bit.
  • Compiles and works on big and little endian systems.
  • The only dependency is on zlib.


  • Swift Tools 5.0.0
View More Packages from this Author


  • None
Last updated: Sun Dec 04 2022 16:31:29 GMT-0500 (GMT-05:00)