Skip to content

Helper project that allows libxlsxwriter to be used in Qt. libxlsxwriter is a C library for creating Excel XLSX files.

License

Notifications You must be signed in to change notification settings

wyyrepo/Qlibxlsxwriter

 
 

Repository files navigation

Qlibxlsxwriter

Read this in other languages: English, 🇰🇷 한국어

  • Qlibxlsxwriter is a helper project that allows libxlsxwriter to be used in Qt.
  • libxlsxwriter is a C library for creating Excel XLSX files. 👍

Sample (Hello World!)

// main.cpp
//
// Qlibxlsxwriter MIT license     https://github.com/j2doll/Qlibxlsxwriter
// libxlsxwriter  FreeBSD license https://github.com/jmcnamara/libxlsxwriter

#include <QCoreApplication>

#include "xlsxwriter.h"

int main(int argc, char **argv)
{
     QCoreApplication app(argc, argv); // it is a Qt code.

     // See Tutorial 1: Create a simple XLSX file.
     // http://libxlsxwriter.github.io/tutorial01.html

     /* Some data we want to write to the worksheet. */
     struct expense {
         char item[32];
         int  cost;
     };
     struct expense expenses[] = {
         {"Rent", 1000},
         {"Gas",   100},
         {"Food",  300},
         {"Gym",    50},
     };


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

     /* Start from the first cell. Rows and columns are zero indexed. */
     int row = 0;
     int col = 0;

     /* Iterate over the data and write it out element by element. */
     for (row = 0; row < 4; row++) {
         worksheet_write_string(worksheet, row, col,     expenses[row].item, NULL);
         worksheet_write_number(worksheet, row, col + 1, expenses[row].cost, NULL);
     }

     /* Write a total using a formula. */
     worksheet_write_string (worksheet, row, col,     "Total",       NULL);
     worksheet_write_formula(worksheet, row, col + 1, "=SUM(B1:B4)", NULL);

     /* Save the workbook and free any allocated memory. */
     return workbook_close(workbook);
}

Test Environment

License and links

📫 Contact

Similar projects

  • QXlsx is excel file(*.xlsx) reader/writer library.
  • Because QtXlsx is no longer supported(2014), I created a new project that is based on QtXlsx. (2017-)
  • Development language of QXlsx is C++. (with Qt 5.x)
  • You don't need to use static library or dynamic shared object using QXlsx. 👍

  • Qxlnt is a helper project that allows xlnt to be used in Qt.
  • xlnt is a excellent library for using xlsx Excel files. 👍
  • I was looking for a way to make it easy to use in Qt. Of course, cmake is compatible with Qt, but it is not convenient to use. So I created Qxlnt.

About

Helper project that allows libxlsxwriter to be used in Qt. libxlsxwriter is a C library for creating Excel XLSX files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 99.1%
  • Other 0.9%