2018-05-26 12:20:33 +09:00
|
|
|
# QXlsx
|
2017-08-20 17:04:19 +09:00
|
|
|
|
2018-05-11 14:39:38 +09:00
|
|
|
> *Read this in other languages: [English](README.md), :kr: [한국어](README.ko.md)*
|
2017-08-20 17:04:19 +09:00
|
|
|
|
2018-04-19 16:17:18 +09:00
|
|
|
![](markdown.data/IMG_0016.PNG)
|
2017-10-05 14:35:06 +09:00
|
|
|
|
2018-04-23 10:16:08 +09:00
|
|
|
## Excel(xlsx) reader/writer library
|
2017-10-21 16:41:24 +09:00
|
|
|
* QXlsx is excel file(*.xlsx) reader/writer library.
|
2018-05-17 20:20:17 +09:00
|
|
|
* Because QtXlsx is no longer supported(2014), I created a new project that is based on QtXlsx. (2017-)
|
2018-04-26 10:18:24 +09:00
|
|
|
* Development language of QXlsx is C++. (with Qt 5.x)
|
2018-04-26 10:23:29 +09:00
|
|
|
* You don't need to use static library or dynamic shared object using QXlsx.
|
2018-04-23 10:10:09 +09:00
|
|
|
|
2018-04-19 16:54:42 +09:00
|
|
|
![](markdown.data/comp.png)
|
2018-04-23 10:10:09 +09:00
|
|
|
|
2017-10-09 21:11:25 +09:00
|
|
|
## License
|
2018-04-19 16:17:18 +09:00
|
|
|
* QXlsx is licensed under the MIT License https://opensource.org/licenses/MIT
|
|
|
|
* QtXlsx License (See Debao Zhang (2014) site) : https://github.com/dbzhang800/QtXlsxWriter
|
|
|
|
* Qt License (See Qt Company site) : https://www.qt.io/
|
2017-10-09 21:11:25 +09:00
|
|
|
|
2018-04-19 16:17:18 +09:00
|
|
|
## Sample (Hello excel)
|
2018-04-19 16:36:59 +09:00
|
|
|
|
2018-05-11 14:39:38 +09:00
|
|
|
### :one: Writing excel file(*.xlsx)
|
2017-10-09 21:08:32 +09:00
|
|
|
```cpp
|
|
|
|
QXlsx::Document xlsx;
|
2017-10-17 18:34:37 +09:00
|
|
|
xlsx.write("A1", "Hello Qt!"); // write "Hello Qt!" to cell(A,1). it's shared string.
|
|
|
|
xlsx.saveAs("Test.xlsx"); // save the document as 'Test.xlsx'
|
2017-10-09 21:08:32 +09:00
|
|
|
```
|
2018-04-19 16:36:59 +09:00
|
|
|
|
2018-05-11 14:39:38 +09:00
|
|
|
### :two: Reading excel file(*.xlsx)
|
2017-10-09 21:08:32 +09:00
|
|
|
```cpp
|
2017-10-17 19:01:47 +09:00
|
|
|
Document xlsx("Test.xlsx"); // load excel file
|
|
|
|
if (!xlsx.isLoadPackage()) { // failed to load excel
|
2017-10-21 16:41:24 +09:00
|
|
|
return;
|
2017-10-17 19:01:47 +09:00
|
|
|
}
|
2017-10-17 19:02:56 +09:00
|
|
|
int row = 1; int col = 2;
|
|
|
|
Cell* cell = xlsx.cellAt(row, col); // get cell pointer. (row is 1. column is 2.)
|
2017-10-09 21:08:32 +09:00
|
|
|
if ( cell == NULL )
|
2017-10-21 16:41:24 +09:00
|
|
|
continue; // cell vaule is not set
|
2017-10-17 18:33:26 +09:00
|
|
|
QVariant var = cell->readValue(); // read cell value (number(double), QDateTime, QString ...)
|
|
|
|
qint32 styleNo = cell->styleNumber(); // read cell style number
|
2017-10-09 21:08:32 +09:00
|
|
|
if ( styleNo >= 0 )
|
|
|
|
qDebug() << row << " " << var << " , style:" << styleNo;
|
|
|
|
else
|
|
|
|
qDebug() << row << " " << var;
|
|
|
|
```
|
|
|
|
|
2018-06-02 12:08:14 +09:00
|
|
|
## How to set up
|
2018-06-02 11:39:09 +09:00
|
|
|
* See [How to setup QXlsx project](HowToSetProject.md)
|
2017-10-09 21:08:32 +09:00
|
|
|
|
2017-09-02 14:41:08 +09:00
|
|
|
## Test environment
|
2018-04-19 16:36:59 +09:00
|
|
|
Test Environment is below.
|
2018-04-23 10:10:09 +09:00
|
|
|
- Qt 5.10.1 (MingW/Windows 32bit)
|
2018-04-19 19:18:27 +09:00
|
|
|
- Qt 5.9.2 (MingW/Windows 32bit)
|
2018-04-19 16:36:59 +09:00
|
|
|
- Qt 5.9.1 (Visual Studio 2017/Windows 64bit)
|
|
|
|
- Qt 5.9.1 (Visual Studio 2017/Windows 32bit)
|
|
|
|
- Qt 5.9.1 (MingW/Windows 32bit)
|
|
|
|
- Qt 5.9.1 (Ubuntu 16/Linux x64)
|
|
|
|
- Qt 5.6.0 (MingW/Windows 32bit)
|
|
|
|
- Qt 5.5.1 (MingW/Windows 32bit)
|
|
|
|
- Qt 5.5.0 (Ubuntu 17/Linux i686)
|
|
|
|
- Qt 5.2.0 (Ubuntu 14/Linux x64)
|
|
|
|
- Qt 5.0.1 (MingW/Windows 32bit)
|
2017-10-17 18:48:33 +09:00
|
|
|
|
2018-04-19 16:17:18 +09:00
|
|
|
## To Test
|
2017-10-17 18:48:33 +09:00
|
|
|
The following tests should be performed.
|
2018-04-23 10:10:09 +09:00
|
|
|
- Microsoft Excel
|
2018-04-19 16:36:59 +09:00
|
|
|
- Google Spreadsheet
|
|
|
|
- LibreOffice Calc Spreasheet
|
2018-04-19 16:17:18 +09:00
|
|
|
|
|
|
|
![](markdown.data/LibreOffice-Google-XLSX.png)
|
2017-10-17 18:48:33 +09:00
|
|
|
|
2018-04-19 16:36:59 +09:00
|
|
|
## Contacts
|
2018-04-19 17:14:23 +09:00
|
|
|
* [https://github.com/j2doll/QXlsx](https://github.com/j2doll/QXlsx)
|
2018-05-11 14:39:38 +09:00
|
|
|
* :email: [j2doll@gmail.com](mailto:j2doll@gmail.com)
|
2018-04-19 16:17:18 +09:00
|
|
|
* Hi! I'm j2doll. My native language is not English and my English is not fluent. Please, use EASY English. :-)
|