Skip to content
Nim bindings for libxlsxwriter
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Nimlibxlsxwriter is a Nim wrapper for the libxlsxwriter library.

Nimlibxlsxwriter is distributed as a Nimble package and depends on nimgen and c2nim to generate the wrappers. The libxlsxwriter source code is downloaded using Git so having git in the path is required.


Nimlibxlsxwriter can be installed via Nimble:

> nimble install nimgen

> nimble install nimlibxlsxwriter

> nimble setup nimlibxlsxwriter


import nimlibxlsxwriter/xlsxwriter

proc main() =
  # Create a new workbook and add a worksheet
  var workbook: ptr lxw_workbook = workbook_new("demo.xlsx")
  var worksheet: ptr lxw_worksheet = workbook_add_worksheet(workbook, nil)

  # Add a format.
  var format: ptr lxw_format = workbook_add_format(workbook)

  # Set the bold property for the format

  # Change the column width for clarity.
  discard worksheet_set_column(worksheet, 0, 0, 20, nil)

  # Write some simple text.
  discard worksheet_write_string(worksheet, 0, 0, "Hello", nil)

  # Text with formatting.
  discard worksheet_write_string(worksheet, 1, 0, "World", format)

  # Write some numbers.
  discard worksheet_write_number(worksheet, 2, 0, 123, nil)
  discard worksheet_write_number(worksheet, 3, 0, 123.456, nil)

  # Insert an image.
  discard worksheet_insert_image(worksheet, 1, 2, "logo.png");

  discard workbook_close(workbook)


Refer to the tests diretory for examples on how the library can be used.


Nimlibxlsxwriter wraps the libxlsxwriter source code and all licensing terms of libxlsxwriter apply to the usage of this package.

Credits go out to c2nim as well without which this package would be greatly limited in its abilities.


Nimlibxlsxwriter is a work in progress and any feedback or suggestions are welcome. It is hosted on GitHub and issues, forks and PRs are most appreciated.

You can’t perform that action at this time.