Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to export data to xls by Qt

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to export data to xls by Qt". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. Preface

Import and export data to csv due to simple syntax and limited application scenarios, so it is necessary to create another wheel to export data to xls, which is constantly adjusted and optimized through decades of project experience. In particular, I remember that the first version of v0.01 was completed around 2011, when the company's project was running on an embedded board and needed to export police records and copy them to the computer for printing. because the embedded system did not and could not install software such as excel, I bravely studied the xls file in xml format and combined it into a simple export data according to that rule, which was theoretically earlier than QtXlsx. I didn't find the open source wheel of QtXlsx until about 2015, and I happen to have the same idea, all using xml format data. QtXlsx focuses on various formats of data cells to make a complete general-purpose components, etc., while my wheel is more inclined to specific application scenarios, directly facing stupid users, passing in table names, fields collection of a few simple information (now directly put to the structural data), you can directly brush the exported data, and even now support directly into QTableWidget, QTableView control on the line, not too simple and cool.

Parameters supported by the structure:

File name

Table name

Main title

Subtitle

Subtitle 1

Subtitle 2

Field name collection

Field width set

Content collection

Line content separator

Child content separator

Border width

Auto-fill data type is enabled by default

If the data cell style is not turned on by default, it can save about 30% of the file size.

Random color

Random color column index set

Check column

Check type

Check value

Check color

II. Functional features

The component also integrates export data to csv, xls, pdf, and print data.

All operations provide static methods without new, and various parameters such as data and properties are set with structural data, which is very convenient.

It also supports QTableView, QTableWidget, QStandardItemModel, QSqlTableModel and other data sources.

Provide static methods that are directly passed into QTableView and QTableWidget controls to automatically identify column names, column widths, and data contents.

Each set of features provides separate and complete examples, annotated in detail, and is very suitable for all stages of Qter programmers.

Original export data mechanism, does not rely on any office components or operating systems and other third-party libraries, and supports embedded linux.

The speed is so fast that it takes only 2 seconds to complete 100000 rows of data in nine fields.

It only takes four steps to start rapidly exporting large amounts of data, such as 100W records to Excel.

At the same time, it provides direct write data interface and multi-thread write data interface without card main interface.

The title, subtitle and table name can be set.

You can set the field name, column name, and column width of the exported data.

Automatic stretch filling can be set at the end of the column, and the default stretch is more beautiful.

You can set whether to enable check filtering data, and the special color display of the data that conforms to the rules when enabled.

You can specify check columns, check rules, check values, and check value data types.

Verification rules support accurate = =, greater than >, greater than or equal to > =, less than

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report