Libxlsxwriter: library for creating Excel XLSX files.

I've been looking for a library to write an XLS / XLSX file to export data from a datalogger.

I currently need to export the data to CSV and then convert to XLS using a computer.

I saw that a small Time Attendance Clock, which apparently doesn't have that much processing power, can write the XLS file and save it to a USB stick, similar to this:

Time Attendance Clock Output Attendance Report Directly USB.jpg

So I don't believe the Arduino doesn't have a library that writes the XLS / XLSX file yet.

I found this library: Libxlsxwriter

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.
Data validation and drop down lists.
Worksheet PNG/JPEG images.
Memory optimization mode for writing large files.
Source code available on GitHub.
FreeBSD license.
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.

Here is an example that was used to create the spreadsheet shown above:

#include "xlsxwriter.h"

int main() {

    /* Create a new workbook and add a worksheet. */
    lxw_workbook  *workbook  = workbook_new("demo.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    /* Add a format. */
    lxw_format *format = workbook_add_format(workbook);

    /* Set the bold property for the format */

    /* Change the column width for clarity. */
    worksheet_set_column(worksheet, 0, 0, 20, NULL);

    /* Write some simple text. */
    worksheet_write_string(worksheet, 0, 0, "Hello", NULL);

    /* Text with formatting. */
    worksheet_write_string(worksheet, 1, 0, "World", format);

    /* Write some numbers. */
    worksheet_write_number(worksheet, 2, 0, 123,     NULL);
    worksheet_write_number(worksheet, 3, 0, 123.456, NULL);

    /* Insert an image. */
    worksheet_insert_image(worksheet, 1, 2, "logo.png");


    return 0;

I tried compiling for Arduino but errors occurred (because it is not "C++" and there seem to be some differences between the arduino IDE libraries themselves, such as different ESP32 errors. Arduino DUE and STM32F1 the same errors occur).

After leaving all files in a single folder, and editing the file headers to their new location, it was possible to compile the first line of sample code. But the second line already generates an error:

c:/arduino ide/arduino-1.8.10-windows-portable/portable/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/armv7-m\libc.a(lib_a-openr.o): In function `_open_r':

openr.c:(.text._open_r+0x10): undefined reference to `_open'

c:/arduino ide/arduino-1.8.10-windows-portable/portable/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/armv7-m\libc.a(lib_a-unlinkr.o): In function `_unlink_r':

unlinkr.c:(.text._unlink_r+0xc): undefined reference to `_unlink'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Due (Programming Port).

Could anyone help compile this library with the arduino IDE? (332 KB) (761 KB)

Time Attendance Clock Output Attendance Report Directly USB.jpg

Take a look at PLX-DAQ.

Maybe not quite what you want but quite versatile in the excel sphere.
There is a whole thread to the topic.


Thanks, I also found libraries for python, and it looks like it might work with a micropython ESP32, maybe it's a more affordable alternative at the moment.