mirror of
https://github.com/QtExcel/QXlsx.git
synced 2025-01-16 04:42:53 +08:00
testing for issue #95
This commit is contained in:
parent
a0e1f2d7aa
commit
bee1f3fc70
@ -7,6 +7,9 @@
|
||||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QColor>
|
||||
#include <QImage>
|
||||
#include <QRgb>
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
@ -18,39 +21,41 @@ using namespace std;
|
||||
#include "xlsxrichstring.h"
|
||||
#include "xlsxworkbook.h"
|
||||
|
||||
int test91( QVector<QVariant> params );
|
||||
int test95( QVector<QVariant> params );
|
||||
|
||||
int test( QVector<QVariant> params )
|
||||
{
|
||||
qDebug() << "[debug] current path : " << QDir::currentPath();
|
||||
return test91( params );
|
||||
return test95( params );
|
||||
}
|
||||
|
||||
// tested in Qt 5.14.1, MingW 7.3.0 64bit
|
||||
int test91( QVector<QVariant> params )
|
||||
int test95( QVector<QVariant> params )
|
||||
{
|
||||
using namespace QXlsx;
|
||||
|
||||
Document doc(":/91.xlsx"); // made by ms excel 2019
|
||||
if (!doc.isLoadPackage()) {
|
||||
qDebug() << "Failed to load xlsx.";
|
||||
return (-1);
|
||||
}
|
||||
Document xlsx;
|
||||
|
||||
QXlsx::CellRange range = doc.dimension();
|
||||
for (int i = 2; i < range.rowCount() + 1; i++)
|
||||
for (int i=0; i<10; ++i)
|
||||
{
|
||||
for (int j = 1; j < range.columnCount()+1; j++)
|
||||
{
|
||||
QString dataStr;
|
||||
auto tmpCell = doc.cellAt(i, j);
|
||||
if(tmpCell)
|
||||
{
|
||||
dataStr = tmpCell->value().toString().trimmed();
|
||||
qDebug() << dataStr;
|
||||
}
|
||||
}
|
||||
QImage image(40, 30, QImage::Format_RGB32);
|
||||
image.fill( uint(qrand() % 16581375) );
|
||||
|
||||
int index = xlsx.insertImage( 10*i, 5, image );
|
||||
|
||||
QImage img;
|
||||
if ( xlsx.getImage( index, img ) )
|
||||
{
|
||||
QString filename;
|
||||
filename = QString("image %1.png").arg( index );
|
||||
img.save( filename );
|
||||
|
||||
qDebug() << " [image index] " << index;
|
||||
}
|
||||
}
|
||||
xlsx.saveAs("image1.xlsx");
|
||||
|
||||
QXlsx::Document xlsx2("image1.xlsx");
|
||||
xlsx2.saveAs("image2.xlsx");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
QVariant read(int row, int col) const;
|
||||
|
||||
int insertImage(int row, int col, const QImage &image);
|
||||
bool getImage(int imageIndex, QImage& img);
|
||||
|
||||
Chart *insertChart(int row, int col, const QSize &size);
|
||||
|
||||
|
@ -51,7 +51,9 @@ public:
|
||||
|
||||
DrawingAnchor(Drawing *drawing, ObjectType objectType);
|
||||
virtual ~DrawingAnchor();
|
||||
|
||||
void setObjectPicture(const QImage &img);
|
||||
bool getObjectPicture(QImage &img);
|
||||
|
||||
void setObjectGraphicFrame(QSharedPointer<Chart> chart);
|
||||
|
||||
|
@ -1,43 +1,8 @@
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
|
||||
** All right reserved.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
****************************************************************************/
|
||||
// xlsxmediafile_p.h
|
||||
|
||||
#ifndef QXLSX_XLSXMEDIAFILE_H
|
||||
#define QXLSX_XLSXMEDIAFILE_H
|
||||
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt Xlsx API. It exists for the convenience
|
||||
// of the Qt Xlsx. This header file may change from
|
||||
// version to version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
|
||||
#include <QString>
|
||||
@ -51,6 +16,7 @@ public:
|
||||
MediaFile(const QString &fileName);
|
||||
MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType=QString());
|
||||
|
||||
public:
|
||||
void set(const QByteArray &bytes, const QString &suffix, const QString &mimeType=QString());
|
||||
QString suffix() const;
|
||||
QString mimeType() const;
|
||||
@ -64,8 +30,8 @@ public:
|
||||
void setFileName(const QString &name);
|
||||
QString fileName() const;
|
||||
|
||||
private:
|
||||
QString m_fileName; //...
|
||||
protected:
|
||||
QString m_fileName;
|
||||
QByteArray m_contents;
|
||||
QString m_suffix;
|
||||
QString m_mimeType;
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
Cell *cellAt(int row, int column) const;
|
||||
|
||||
int insertImage(int row, int column, const QImage &image);
|
||||
bool getImage(int imageIndex, QImage& img);
|
||||
Chart *insertChart(int row, int column, const QSize &size);
|
||||
|
||||
bool mergeCells(const CellRange &range, const Format &format=Format());
|
||||
|
@ -649,6 +649,14 @@ int Document::insertImage(int row, int column, const QImage &image)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Document::getImage(int imageIndex, QImage& img)
|
||||
{
|
||||
if (Worksheet *sheet = currentWorksheet())
|
||||
return sheet->getImage(imageIndex, img);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Creates an chart with the given \a size and insert it to the current
|
||||
* active worksheet at the position \a row, \a col.
|
||||
|
@ -74,6 +74,15 @@ void DrawingAnchor::setObjectPicture(const QImage &img)
|
||||
m_objectType = Picture;
|
||||
}
|
||||
|
||||
bool DrawingAnchor::getObjectPicture(QImage &img)
|
||||
{
|
||||
if ( m_pictureFile == nullptr )
|
||||
return false;
|
||||
|
||||
bool ret = img.loadFromData( m_pictureFile->contents() );
|
||||
return ret;
|
||||
}
|
||||
|
||||
//{{ liufeijin
|
||||
void DrawingAnchor::setObjectShape(const QImage &img)
|
||||
{
|
||||
|
@ -1117,6 +1117,35 @@ int Worksheet::insertImage(int row, int column, const QImage &image)
|
||||
return imageIndex;
|
||||
}
|
||||
|
||||
bool Worksheet::getImage(int imageIndex, QImage& img)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
|
||||
if( imageIndex <= (-1) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( d->drawing == nullptr )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int realImageIndex = imageIndex - 1; // minus one
|
||||
|
||||
DrawingAnchor* danchor = d->drawing->anchors.at( realImageIndex );
|
||||
// QSharedPointer<Drawing> // for multithread
|
||||
if ( danchor == nullptr )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret= danchor->getObjectPicture(img);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* Creates an chart with the given \a size and insert
|
||||
* at the position \a row, \a column.
|
||||
|
@ -40,13 +40,18 @@
|
||||
- QXlsx 는 MIT 라이센스 입니다. [https://github.com/QtExcel/QXlsx](https://github.com/QtExcel/QXlsx)
|
||||
- 다음과 같은 놀라운 프로젝트들을 만들어 주신 분들에게 감사의 말씀을 올립니다. :+1:
|
||||
- Qt 는 LGPL v3 라이센스 또는 상업용 라이센스 입니다. [https://www.qt.io/](https://www.qt.io/)
|
||||
- QtXlsx 는 MIT 라이센스 입니다. [https://github.com/dbzhang800/QtXlsxWriter](https://github.com/dbzhang800/QtXlsxWriter)
|
||||
- QtXlsx 는 MIT 라이센스 입니다. :+1: [https://github.com/dbzhang800/QtXlsxWriter](https://github.com/dbzhang800/QtXlsxWriter)
|
||||
- Qt-Table-Printer 는 BSD 3-Clause 라이센스 입니다. [https://github.com/T0ny0/Qt-Table-Printer](https://github.com/T0ny0/Qt-Table-Printer)
|
||||
- recurse 는 MIT 라이센스 입니다. [https://github.com/pkoretic/recurse](https://github.com/pkoretic/recurse)
|
||||
- libfort 는 MIT 라이센스 입니다. [https://github.com/seleznevae/libfort](https://github.com/seleznevae/libfort)
|
||||
- colorprintf 는 MIT 라이센스 입니다. [https://github.com/VittGam/colorprintf](https://github.com/VittGam/colorprintf)
|
||||
- HelloActions-Qt 는 MIT 라이센스 입니다. [https://github.com/jaredtao/HelloActions-Qt](https://github.com/jaredtao/HelloActions-Qt)
|
||||
|
||||
## 축하
|
||||
- 우리의 코드가 북극에 갑니다.
|
||||
![](markdown.data/arcvalut.png)
|
||||
- 자세한 정보는 링크를 보세요. https://archiveprogram.github.com/
|
||||
|
||||
## :email: 문의
|
||||
- 이슈를 남겨 주세요. [https://github.com/QtExcel/QXlsx/issues](https://github.com/QtExcel/QXlsx/issues)
|
||||
- 프로젝트 참여에 관심이 있으신 분은 이슈로 연락주세요.
|
||||
|
13
README.md
13
README.md
@ -11,9 +11,9 @@
|
||||
- You can also use it as a static library.
|
||||
|
||||
## How to use
|
||||
- See [examples](Example.md).
|
||||
- See [wiki](https://github.com/QtExcel/QXlsx/wiki).
|
||||
- See [FAQ](https://github.com/QtExcel/QXlsx/wiki/FAQ).
|
||||
- See [examples](Example.md)
|
||||
- See [wiki](https://github.com/QtExcel/QXlsx/wiki)
|
||||
- See [FAQ](https://github.com/QtExcel/QXlsx/wiki/FAQ)
|
||||
|
||||
## How to set up (Installation)
|
||||
|
||||
@ -40,13 +40,18 @@
|
||||
- QXlsx is under MIT license. [https://github.com/QtExcel/QXlsx](https://github.com/QtExcel/QXlsx)
|
||||
- Thank you for creating the following amazing projects. :+1:
|
||||
- Qt is under LGPL v3 license or Commercial license. [https://www.qt.io/](https://www.qt.io/)
|
||||
- QtXlsxWriter is under MIT license. [https://github.com/dbzhang800/QtXlsxWriter](https://github.com/dbzhang800/QtXlsxWriter)
|
||||
- QtXlsxWriter is under MIT license. :+1: [https://github.com/dbzhang800/QtXlsxWriter](https://github.com/dbzhang800/QtXlsxWriter)
|
||||
- Qt-Table-Printer is under BSD 3-Clause license. [https://github.com/T0ny0/Qt-Table-Printer](https://github.com/T0ny0/Qt-Table-Printer)
|
||||
- recurse is under MIT license. [https://github.com/pkoretic/recurse](https://github.com/pkoretic/recurse)
|
||||
- libfort is under MIT license. [https://github.com/seleznevae/libfort](https://github.com/seleznevae/libfort)
|
||||
- colorprintf is under MIT license. [https://github.com/VittGam/colorprintf](https://github.com/VittGam/colorprintf)
|
||||
- HelloActions-Qt is under MIT license. [https://github.com/jaredtao/HelloActions-Qt](https://github.com/jaredtao/HelloActions-Qt)
|
||||
|
||||
## Congratulations
|
||||
- Our code is going to the North Pole.
|
||||
![](markdown.data/arcvalut.png)
|
||||
- See link for more information. https://archiveprogram.github.com/
|
||||
|
||||
## :email: Contact
|
||||
- Leave me a issue. [https://github.com/QtExcel/QXlsx/issues](https://github.com/QtExcel/QXlsx/issues)
|
||||
- If you are interested in participating in the project, please contact us by issue.
|
||||
|
@ -4,18 +4,38 @@
|
||||
#include <QtCore>
|
||||
#include <QDebug>
|
||||
#include <QtGui>
|
||||
#include <QVector>
|
||||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QColor>
|
||||
#include <QImage>
|
||||
#include <QRgb>
|
||||
|
||||
#include "xlsxdocument.h"
|
||||
|
||||
int image()
|
||||
{
|
||||
QXlsx::Document xlsx;
|
||||
QImage image(40, 30, QImage::Format_RGB32);
|
||||
image.fill(Qt::green);
|
||||
using namespace QXlsx;
|
||||
|
||||
Document xlsx;
|
||||
|
||||
for (int i=0; i<10; ++i)
|
||||
{
|
||||
int index = xlsx.insertImage( 10*i, 5, image );
|
||||
qDebug() << " [image index] " << index;
|
||||
QImage image(40, 30, QImage::Format_RGB32);
|
||||
image.fill( uint(qrand() % 16581375) );
|
||||
|
||||
int index = xlsx.insertImage( 10*i, 5, image );
|
||||
|
||||
QImage img;
|
||||
if ( xlsx.getImage( index, img ) )
|
||||
{
|
||||
QString filename;
|
||||
filename = QString("image %1.png").arg( index );
|
||||
img.save( filename );
|
||||
|
||||
qDebug() << " [image index] " << index;
|
||||
}
|
||||
}
|
||||
xlsx.saveAs("image1.xlsx");
|
||||
|
||||
|
BIN
markdown.data/arcvalut.png
Normal file
BIN
markdown.data/arcvalut.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
Loading…
x
Reference in New Issue
Block a user