91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 15KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-08
  • 語言: 數據庫
  • 標簽: QT??EXCEL??SQLITE??

資源簡介

QT讀取excel文件 并可以修改 還有sqlite數據庫 實現了一些 打開文件 保存 等基本功能(打印沒實現)

資源截圖

代碼片段和文件信息

#include?“excelengine.h“
#include?“qt_windows.h“

ExcelEngine::ExcelEngine()
{
????pExcel?????=?NULL;
????pWorkbooks?=?NULL;
????pWorkbook??=?NULL;
????pWorksheet?=?NULL;

????sXlsFile?????=?““;
????nRowCount????=?0;
????nColumnCount?=?0;
????nStartRow????=?0;
????nStartColumn?=?0;

????bIsOpen??=?false;
????bIsValid?=?false;

????HRESULT?r?=?OleInitialize(NULL);
????if?(r?!=?S_OK?&&?r?!=?S_FALSE)
????{
????????qDebug(“Qt:?Could?not?initialize?OLE?(error?%x)“?(unsigned?int)r);
????}
}

ExcelEngine::ExcelEngine(QString?xlsFile)
{
????pExcel?????=?NULL;
????pWorkbooks?=?NULL;
????pWorkbook??=?NULL;
????pWorksheet?=?NULL;

????sXlsFile?????=?xlsFile;
????nRowCount????=?0;
????nColumnCount?=?0;
????nStartRow????=?0;
????nStartColumn?=?0;

????bIsOpen??=?false;
????bIsValid?=?false;

????HRESULT?r?=?OleInitialize(0);
????if?(r?!=?S_OK?&&?r?!=?S_FALSE)
????{
????????qDebug(“Qt:?Could?not?initialize?OLE?(error?%x)“?(unsigned?int)r);
????}

}

ExcelEngine::~ExcelEngine()
{
????if?(?bIsOpen?)
????{
????????//析構前,先保存數據,然后關閉workbook
????????Close();
????}
????OleUninitialize();
}

/**
??*@brief?打開sXlsFile指定的excel報表
??*@return?true?:?打開成功
??*????????false:?打開失敗
??*/
bool?ExcelEngine::Open(UINT?nSheet?bool?visible)
{

????if?(?bIsOpen?)
????{
????????//return?bIsOpen;
????????Close();
????}

????if?(?NULL?==?pExcel?)
????{
????????this->pExcel?=?new?QAxobject(“Excel.Application“this);
????????if?(?pExcel?)
????????{
????????????bIsValid?=?true;
????????}
????????else
????????{
????????????bIsValid?=?false;
????????????bIsOpen??=?false;
????????????return?bIsOpen;
????????}
????????bIsVisible?=?false;
????????pExcel->dynamicCall(“SetVisible(bool)“?bIsVisible);//是否顯示Excel
????}

????if?(?!bIsValid?)
????{
????????bIsOpen??=?false;
????????return?bIsOpen;
????}

????if?(?sXlsFile.isEmpty()?)
????{
????????bIsOpen??=?false;
????????return?bIsOpen;
????}


????bool?ok?=?CreateXlsFile(sXlsFile);
????if?(?!ok?)
????{
????????bIsOpen??=?false;
????????return?bIsOpen;
????}

????nCurrSheet?=?nSheet;
??//bIsVisible?=?visible;

????pWorkbooks?=?pExcel->querySubobject(“WorkBooks“);?//獲取工作簿
????pWorkbook?=??pWorkbooks->querySubobject(“Open(QString?QVariant)“sXlsFileQVariant(0));?//打開xls對應的工作簿
????pWorksheet?=?pWorkbook->querySubobject(“WorkSheets(int)“?nCurrSheet);//打開第一個sheet

????//至此已打開,開始獲取相應屬性
????QAxobject?*usedrange?=?pWorksheet->querySubobject(“UsedRange“);//獲取該sheet的使用范圍對象
????QAxobject?*rows?=?usedrange->querySubobject(“Rows“);
????QAxobject?*columns?=?usedrange->querySubobject(“Columns“);
????qDebug()<<“rows“<????qDebug()<<“columns“<
????//因為excel可以從任意行列填數據而不一定是從00開始,因此要獲取首行列下標
????nStartRow????=?usedrange->property(“Row“).toInt();????//第一行的起始位置
????nStartColumn?=?usedrange->property(“Column“).toInt();?//第一列的起始位置

????nRowCount????=?rows->property(“Count“).toInt();???????//獲取行數
????nColumnCount?=?columns->p

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2012-09-19?08:41??Qxcel_sqlite\
?????文件????????1772??2012-09-04?13:30??Qxcel_sqlite\close-file.png
?????文件???????10201??2012-09-19?11:28??Qxcel_sqlite\excelengine.cpp
?????文件????????2438??2012-09-19?11:32??Qxcel_sqlite\excelengine.h
?????文件?????????493??2012-09-20?14:27??Qxcel_sqlite\jiaoduyi.pro
?????文件????????7988??2012-09-24?15:50??Qxcel_sqlite\jiaoduyi.pro.user
?????文件????????1344??2012-09-19?16:11??Qxcel_sqlite\judgeFileAndDeal.cpp
?????文件?????????672??2012-09-19?15:01??Qxcel_sqlite\judgeFileAndDeal.h
?????文件?????????377??2012-09-20?17:31??Qxcel_sqlite\main.cpp
?????文件???????10578??2012-09-24?08:44??Qxcel_sqlite\mywindow.cpp
?????文件????????2038??2012-09-19?15:49??Qxcel_sqlite\mywindow.h
?????文件????????1145??2012-09-10?15:04??Qxcel_sqlite\mywindow.ui
?????文件????????1117??2012-09-04?13:29??Qxcel_sqlite\open-file.png
?????文件?????????131??2012-09-04?15:28??Qxcel_sqlite\source.qrc

評論

共有 條評論