File: main.cpp

package info (click to toggle)
labplot 2.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,500 kB
  • sloc: cpp: 241,048; ansic: 6,324; python: 915; xml: 400; yacc: 237; sh: 221; awk: 35; makefile: 11
file content (37 lines) | stat: -rw-r--r-- 1,408 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>

#include <QApplication>

#include "labplot.h"

int main(int argc, char* argv[]) {
	QApplication app(argc, argv);

	XLSXFilter filter;

	filter.setCurrentSheet(QStringLiteral("Sheet1"));
	filter.setCurrentRange(QStringLiteral("A1:D7"));
	filter.setFirstRowAsColumnNames(true);

	Spreadsheet spreadsheet(QStringLiteral("test"), false);

	filter.readDataFromFile(QStringLiteral("data.xlsx"), &spreadsheet, AbstractFileFilter::ImportMode::Replace);

	if (!filter.lastError().isEmpty()) {
		std::cout << "Import error: " << filter.lastError().toStdString() << std::endl;
		return -1;
	}

	std::cout << "Number of columns: " << spreadsheet.columnCount() << std::endl;
	std::cout << "Number of rows: " << spreadsheet.rowCount() << std::endl;

	spreadsheet.column(0)->setColumnMode(AbstractColumn::ColumnMode::Text);
	spreadsheet.column(1)->setColumnMode(AbstractColumn::ColumnMode::Integer);
	spreadsheet.column(2)->setColumnMode(AbstractColumn::ColumnMode::Double);
	spreadsheet.column(3)->setColumnMode(AbstractColumn::ColumnMode::Day);

	std::cout << "First Name: " << spreadsheet.column(0)->textAt(1).toStdString() << std::endl;
	std::cout << "Age: " << spreadsheet.column(1)->integerAt(1) << std::endl;
	std::cout << "Height: " << spreadsheet.column(2)->doubleAt(1) << std::endl;
	std::cout << "Date of Birth: " << spreadsheet.column(3)->dateAt(1).toString().toStdString() << std::endl;
}