当前位置:网站首页>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
边栏推荐
- idea:使用easyYapi插件导出yapi接口
- The simple problem of leetcode is to calculate the numerical sum of strings
- Compiling principle questions - with answers
- Draw a circle quickly in MATLAB (the one that can be drawn directly given the coordinates and radius of the center of the circle)
- 【学习】从零开始的音视频开发(9)——NuPlayer
- 2022.4.11-4.17 AI industry weekly (issue 93): the dilemma of AI industry
- Multi vision slam
- LeetCode中等题之旋转函数
- Manipulator motion planning in 3C assembly
- 微信小程序 catchtap=“toDetail“ 事件问题
猜你喜欢
Green apple film and television system source code film and television aggregation film and television navigation film and television on demand website source code
AAAI 2022 recruit speakers!!
社区团购小程序源码+界面diy+附近团长+供应商+拼团+菜谱+秒杀+预售+配送+直播
396. Rotate Function
2022.4.11-4.17 AI industry weekly (issue 93): the dilemma of AI industry
为什么会存在1px问题?怎么解决?
The whole house intelligence bet by the giant is driving the "self revolution" of Hisense, Huawei and Xiaomi
通过实现参数解析器HandlerMethodArgumentResolver接口来自定义注解
一篇文章看懂变量提升(hoisting)
怎么读书读论文
随机推荐
单点登录 SSO
Kubernetes in browser and IDE | interactive learning platform killercoda
Qt编译QtXlsx库
WordPress love navigation theme 1.1.3 simple atmosphere website navigation source code website navigation source code
Campus transfer second-hand market source code download
扎心了!一女子发朋友圈羡慕别人按时发工资被开除,连点赞的同事也一同被开除了...
Listed on the Shenzhen Stock Exchange: the market value is 5.2 billion yuan. Lu is the East and his daughter is American
Interesting JS code
How to read books and papers
Vowel substring in statistical string of leetcode simple problem
一个没啥L用,但可以装X的IDEA插件
2022.4.11-4.17 AI industry weekly (issue 93): the dilemma of AI industry
php生成短链接:将数字转成字母,将字母转成数字
Talk about the basic but not simple stock data
js将树形结构数据转为一维数组数据
欧圣电气深交所上市:市值52亿 陆为东父女为美国籍
AQS & ReentrantLock 实现原理
[learning] audio and video development from scratch (9) -- nuplayer
JS common array methods
浅谈ES6尾调优化