You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-12Lines changed: 57 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@
14
14
-[Usage](#usage)
15
15
-[Classes](#classes)
16
16
17
-
# About project
17
+
##About project
18
18
This is a library for importing and exporting data. Created as a result of the division of Volbx project code and moving parts of it to an independent library. The library contains classes:
19
19
+ ExportData (base class for exporting)
20
20
+ ExportXlsx
@@ -73,13 +73,13 @@ Check my other project `Volbx` for real world CMake integration.
73
73
| Zlib | 1.3.1 | 1.3.1 |
74
74
| QuaZip | 1.4 | 1.4 |
75
75
76
-
# Usage
76
+
##Usage
77
77
The easiest way is to check the examples' subproject, where you can find how to create and interact with each class included in this library.
78
78
Alternatively, tests in a subproject can be checked. Usage can also be found in my other project called Volbx where classes from this library are used for exporting and importing data.
79
79
80
-
# Classes
81
-
## Classes used for importing data
82
-
### ImportSpreadsheet
80
+
##Classes
81
+
###Classes used for importing data
82
+
####ImportSpreadsheet
83
83
Base class for spreadsheet-related import classes. The following pure virtual methods need to be implemented when creating a new derived class:
84
84
+`getSheetNames()`
85
85
+`getColumnNames()`
@@ -92,7 +92,7 @@ Base class for spreadsheet-related import classes. The following pure virtual me
92
92
Emits signal `progressPercentChanged` during loading data.
93
93
94
94
Importing can be done from objects with the interface QIODevice: files on disk, files from resources, QBuffer and more.
95
-
### ImportXlsx
95
+
####ImportXlsx
96
96
Class used to import data from .xlsx files. Basic usage:
97
97
```cpp
98
98
QFile xlsxFile("example.xlsx");
@@ -101,16 +101,16 @@ auto [success, xlsxData] = importXlsx.getData("SheetName", {});
101
101
```
102
102
Check `example` and `test` subprojects for more advanced use cases.
103
103
Take note that .xlsx files store strings separately. ImportXlsx follows that convention and provides `getSharedStrings()` to retrieve those.
104
-
### ImportOds
104
+
#### ImportOds
105
105
Class used to import data from .ods files. Basic usage:
106
106
```cpp
107
107
QFile odsFile("example.ods");
108
108
ImportOds importOds(odsFile);
109
109
auto [success, odsData] = importOds.getData("SheetName", {});
110
110
```
111
111
Check `example` and `test` subprojects for more advanced use cases.
112
-
## Classes used for exporting data
113
-
### ExportData
112
+
###Classes used for exporting data
113
+
####ExportData
114
114
Base class for export-related classes. The following pure virtual methods need to be implemented when creating a new derived class:
115
115
+`writeContent()`
116
116
+`getEmptyContent()`
@@ -128,7 +128,7 @@ QTableWidget tableWidget;
128
128
ExportXlsx exportXlsx;
129
129
exportXlsx.exportView(tableWidget, exportedZip);
130
130
```
131
-
### ExportDsv
131
+
#### ExportDsv
132
132
Class for exporting data to DSV (Delimiter Separated Values) files. The delimiter is set in the constructor and can be any character (comma, tab, semicolon, ...). CSV or TSV files can be created using this class.
133
133
Three additional methods can be used to customize the output:
134
134
+ `setDateFormat(Qt::DateFormat)` - for setting the output date format to a given one,
@@ -143,7 +143,7 @@ QTableWidget tableWidget;
143
143
ExportDsv exportDsv(',');
144
144
exportDsv.exportView(tableWidget, outFile);
145
145
```
146
-
### ExportXlsx
146
+
####ExportXlsx
147
147
Class for exporting data to .xlsx files.
148
148
Basic usage:
149
149
```cpp
@@ -153,4 +153,49 @@ QTableWidget tableWidget;
153
153
ExportXlsx exportXlsx;
154
154
exportXlsx.exportView(tableWidget, outFile);
155
155
```
156
-
XLSX files are created using the template file `template.xlsx` included in the project via the resource collection file `resources.qrc`.
156
+
XLSX files are created using the template file `template.xlsx` included in the project via the resource collection file `resources.qrc`.
157
+
158
+
## Testing
159
+
For testing purposes, the Qt Test framework is used. Build the project first. Make sure that the `eible-tests` target is built. Modern IDEs supporting CMake also support running tests with monitoring of failures. But in case you would like to run it manually, go to the `build/tests` directory, where the binary `eible-tests` should be available. Launching it should produce the following output on Linux:
160
+
Example run:
161
+
```
162
+
$ ./eible-tests
163
+
********* Start testing of ExportXlsxTest *********
164
+
Config: Using QtTest library 6.5.2, Qt 6.5.2 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 10.3.1 20210422 (Red Hat 10.3.1-1)), ubuntu 24.04
0 commit comments