当前位置:网站首页>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
边栏推荐
- Positioning of high precision welding manipulator
- 如何在SQL Server中导入excel数据,2019版
- 5.6 comprehensive case - RTU-
- 396. Rotate Function
- JS common array methods
- 将实例化对象的方法 给新的对象用
- [effective go Chinese translation] function
- 在MATLAB中快速画圆(给出圆心坐标和半径就能直接画的那种)
- ansible自动化运维详解(一)ansible的安装部署、参数使用、清单管理、配置文件参数及用户级ansible操作环境构建
- [learning] audio and video development from scratch (9) -- nuplayer
猜你喜欢
Idea: export Yapi interface using easyyapi plug-in
Talk about the basic but not simple stock data
一个必看的微信小程序开发指南1-基础知识了解
【解释】get ORA-12838: cannot read/modify an object after modifying it in parallel
Somme numérique de la chaîne de calcul pour un problème simple de leetcode
LeetCode簡單題之計算字符串的數字和
Distributed service governance Nacos
欧圣电气深交所上市:市值52亿 陆为东父女为美国籍
[appium] encountered the problem of switching the H5 page embedded in the mobile phone during the test
PyQt5开发之QTableWidget表头自定义与美化(附源代码下载)
随机推荐
5.6 comprehensive case - RTU-
Common regular expressions
js常用数组方法
Somme numérique de la chaîne de calcul pour un problème simple de leetcode
Vowel substring in statistical string of leetcode simple problem
Online yaml to XML tool
User manual of Chinese version of solidity ide Remix
一款拥有漂亮外表的Typecho简洁主题_Scarfskin 源码下载
扎心了!一女子发朋友圈羡慕别人按时发工资被开除,连点赞的同事也一同被开除了...
3C裝配中的機械臂運動規劃
C语言学习记录——삼십팔 字符串函数使用和剖析(2)
Samsung, March to the west again
岛屿的个数
Brief description of CPU
浅谈ES6尾调优化
Briefly describe the hierarchical strategy of memory
synchronized 实现原理
Situational leaders - Chapter 7, solving performance problems
LeetCoed18. Sum of four numbers
Generate and parse tokens using JWT