当前位置:网站首页>Using qlst excel file
Using qlst excel file
2022-04-23 08:19:00 【Ott_ Glodon】
One 、 Introductory example
Code from QtXlsx Sample file project provided F:\QtProject\QtXlsxWriter-master\examples\xlsx\hello
1、 Generate a excel file

2、 The code is as follows
QtXlsxTest1.pro
QT += core
QT -= gui
QT += xlsx
CONFIG += c++11
TARGET = QtXlsxTest1
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
main.cpp
#include <QCoreApplication>
#include <QtCore>
#include "xlsxdocument.h"
int main()
{
QXlsx::Document xlsx("excel01.xlsx");
//![1]
xlsx.write("A1", "Hello Qt!");
xlsx.write("A2", 12345);
xlsx.write("A3", "=44+33");
xlsx.write("A4", true);
xlsx.write("A5", "http://qt-project.org");
xlsx.write("A6", QDate(2013, 12, 27));
xlsx.write("A7", QTime(6, 30));
xlsx.save();
return 0;
}
Two 、excel File read and write
1、 write in excel file

#include <QCoreApplication>
#include <QtCore>
#include "xlsxdocument.h"
#include <QDebug>
void WriteExcel()
{
QXlsx::Document xlsx;
for(int i = 1; i < 11; i++)
{
for(int j = 1; j < 11; j++)
{
QString sValue = QString("%1_%2").arg(i).arg(j);
xlsx.write(i,j,sValue);
}
}
xlsx.saveAs("WriteExcel.xlsx");
}
2、 Read excel file

void ReadExcel()
{
QXlsx::Document xlsx("WriteExcel.xlsx");
for(int i = 1; i < 11; i++)
{
for(int j = 1; j < 11; j++)
{
QVariant sValue = xlsx.read(i,j);
if(sValue.type() == QVariant::Int)
{
qDebug()<<sValue.toInt();
}
else if(sValue.type() == QVariant::Double)
{
qDebug()<<sValue.toDouble();
}
else if(sValue.type() == QVariant::String)
{
qDebug() << sValue.toString();
}
}
}
}
版权声明
本文为[Ott_ Glodon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230714487187.html
边栏推荐
- Samsung, March to the west again
- The whole house intelligence bet by the giant is driving the "self revolution" of Hisense, Huawei and Xiaomi
- dried food! Point based: differentiable Poisson solver
- JS converts tree structure data into one-dimensional array data
- C language learning record -- use and analysis of string function (2)
- 396. Rotate Function
- AAAI 2022 recruit speakers!!
- dmp引擎工作总结(2021,光剑)
- Compiling principle questions - with answers
- Penetration test interview collection -- HVV---
猜你喜欢

How to import Excel data in SQL server, 2019 Edition

2022.4.11-4.17 AI行业周刊(第93期):AI行业的困局

Install MySQL for Ubuntu and query the average score

396. Rotate Function

clang 如何产生汇编文件

Comparison of indoor positioning methods of several intelligent robots

谈谈那些基础但不简单的股票数据

ansible自动化运维详解(一)ansible的安装部署、参数使用、清单管理、配置文件参数及用户级ansible操作环境构建

Weekly leetcode - 06 array topics 7 ~ 739 ~ 50 ~ offer 62 ~ 26 ~ 189 ~ 9

Community group purchase applet source code + interface DIY + nearby leader + supplier + group collage + recipe + second kill + pre-sale + distribution + live broadcast
随机推荐
nn.Module类的讲解
js将树形结构数据转为一维数组数据
二维01背包
PHP high precision computing
每周leetcode - 06 数组专题 7~739~50~offer 62~26~189~9
LeetCode简单题之计算字符串的数字和
华硕笔记本电脑重装系统后不能读取usb,不能上网
Samsung, March to the west again
vslam PPT
万物互联下如何对设备进行加密
Somme numérique de la chaîne de calcul pour un problème simple de leetcode
An article understands variable lifting
线程的调度(优先级)
干货!以点为形:可微分的泊松求解器
PyQt5开发之QTableWidget表头自定义与美化(附源代码下载)
C outputs a two-dimensional array with the following characteristics.
Penetration test interview collection -- HVV---
CSV column extract column extraction
Comparison of indoor positioning technology
Transformer-XL: Attentive Language ModelsBeyond a Fixed-Length Context 论文总结