mirror of
https://github.com/QtExcel/QXlsx.git
synced 2025-02-06 05:08:22 +08:00
testing image index
This commit is contained in:
parent
dfeb703de2
commit
a0e1f2d7aa
@ -41,7 +41,7 @@ public:
|
|||||||
QVariant read(const CellReference &cell) const;
|
QVariant read(const CellReference &cell) const;
|
||||||
QVariant read(int row, int col) const;
|
QVariant read(int row, int col) const;
|
||||||
|
|
||||||
bool insertImage(int row, int col, const QImage &image);
|
int insertImage(int row, int col, const QImage &image);
|
||||||
|
|
||||||
Chart *insertChart(int row, int col, const QSize &size);
|
Chart *insertChart(int row, int col, const QSize &size);
|
||||||
|
|
||||||
|
@ -85,6 +85,10 @@ protected:
|
|||||||
QSharedPointer<Chart> m_chartFile;
|
QSharedPointer<Chart> m_chartFile;
|
||||||
|
|
||||||
int m_id;
|
int m_id;
|
||||||
|
public:
|
||||||
|
int getm_id();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
// liufeij {{
|
// liufeij {{
|
||||||
void setObjectShape(const QImage &img); // liufeij
|
void setObjectShape(const QImage &img); // liufeij
|
||||||
|
@ -97,7 +97,7 @@ public:
|
|||||||
Cell *cellAt(const CellReference &row_column) const;
|
Cell *cellAt(const CellReference &row_column) const;
|
||||||
Cell *cellAt(int row, int column) const;
|
Cell *cellAt(int row, int column) const;
|
||||||
|
|
||||||
bool insertImage(int row, int column, const QImage &image);
|
int insertImage(int row, int column, const QImage &image);
|
||||||
Chart *insertChart(int row, int column, const QSize &size);
|
Chart *insertChart(int row, int column, const QSize &size);
|
||||||
|
|
||||||
bool mergeCells(const CellRange &range, const Format &format=Format());
|
bool mergeCells(const CellRange &range, const Format &format=Format());
|
||||||
|
@ -641,11 +641,12 @@ QVariant Document::read(int row, int col) const
|
|||||||
* Insert an \a image to current active worksheet at the position \a row, \a column
|
* Insert an \a image to current active worksheet at the position \a row, \a column
|
||||||
* Returns ture if success.
|
* Returns ture if success.
|
||||||
*/
|
*/
|
||||||
bool Document::insertImage(int row, int column, const QImage &image)
|
int Document::insertImage(int row, int column, const QImage &image)
|
||||||
{
|
{
|
||||||
if (Worksheet *sheet = currentWorksheet())
|
if (Worksheet *sheet = currentWorksheet())
|
||||||
return sheet->insertImage(row, column, image);
|
return sheet->insertImage(row, column, image);
|
||||||
return false;
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -821,6 +821,11 @@ void DrawingAnchor::saveXmlObjectPicture(QXmlStreamWriter &writer) const
|
|||||||
writer.writeEndElement(); //xdr:pic
|
writer.writeEndElement(); //xdr:pic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DrawingAnchor::getm_id()
|
||||||
|
{
|
||||||
|
return (this->m_id);
|
||||||
|
}
|
||||||
|
|
||||||
void DrawingAnchor::saveXmlObjectShape(QXmlStreamWriter &writer) const
|
void DrawingAnchor::saveXmlObjectShape(QXmlStreamWriter &writer) const
|
||||||
{
|
{
|
||||||
//{{ liufeijin
|
//{{ liufeijin
|
||||||
|
@ -703,14 +703,19 @@ QList<QSharedPointer<MediaFile> > Workbook::mediaFiles() const
|
|||||||
void Workbook::addMediaFile(QSharedPointer<MediaFile> media, bool force)
|
void Workbook::addMediaFile(QSharedPointer<MediaFile> media, bool force)
|
||||||
{
|
{
|
||||||
Q_D(Workbook);
|
Q_D(Workbook);
|
||||||
if (!force) {
|
|
||||||
for (int i=0; i<d->mediaFiles.size(); ++i) {
|
if (!force)
|
||||||
if (d->mediaFiles[i]->hashKey() == media->hashKey()) {
|
{
|
||||||
|
for (int i=0; i<d->mediaFiles.size(); ++i)
|
||||||
|
{
|
||||||
|
if (d->mediaFiles[i]->hashKey() == media->hashKey())
|
||||||
|
{
|
||||||
media->setIndex(i);
|
media->setIndex(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
media->setIndex(d->mediaFiles.size());
|
media->setIndex(d->mediaFiles.size());
|
||||||
d->mediaFiles.append(media);
|
d->mediaFiles.append(media);
|
||||||
}
|
}
|
||||||
|
@ -1085,17 +1085,21 @@ bool Worksheet::addConditionalFormatting(const ConditionalFormatting &cf)
|
|||||||
* Insert an \a image at the position \a row, \a column
|
* Insert an \a image at the position \a row, \a column
|
||||||
* Returns true on success.
|
* Returns true on success.
|
||||||
*/
|
*/
|
||||||
bool Worksheet::insertImage(int row, int column, const QImage &image)
|
int Worksheet::insertImage(int row, int column, const QImage &image)
|
||||||
{
|
{
|
||||||
Q_D(Worksheet);
|
Q_D(Worksheet);
|
||||||
|
|
||||||
|
int imageIndex = 0;
|
||||||
|
|
||||||
if (image.isNull())
|
if (image.isNull())
|
||||||
return false;
|
return imageIndex;
|
||||||
|
|
||||||
if (!d->drawing)
|
if (!d->drawing)
|
||||||
|
{
|
||||||
d->drawing = QSharedPointer<Drawing>(new Drawing(this, F_NewFromScratch));
|
d->drawing = QSharedPointer<Drawing>(new Drawing(this, F_NewFromScratch));
|
||||||
|
}
|
||||||
|
|
||||||
DrawingOneCellAnchor *anchor = new DrawingOneCellAnchor(d->drawing.data(), DrawingAnchor::Picture);
|
DrawingOneCellAnchor* anchor = new DrawingOneCellAnchor(d->drawing.data(), DrawingAnchor::Picture);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The size are expressed as English Metric Units (EMUs).
|
The size are expressed as English Metric Units (EMUs).
|
||||||
@ -1107,7 +1111,10 @@ bool Worksheet::insertImage(int row, int column, const QImage &image)
|
|||||||
anchor->ext = QSize( int(image.width() * scaleX), int(image.height() * scaleY) );
|
anchor->ext = QSize( int(image.width() * scaleX), int(image.height() * scaleY) );
|
||||||
|
|
||||||
anchor->setObjectPicture(image);
|
anchor->setObjectPicture(image);
|
||||||
return true;
|
|
||||||
|
imageIndex = anchor->getm_id();
|
||||||
|
|
||||||
|
return imageIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -13,7 +13,10 @@ int image()
|
|||||||
QImage image(40, 30, QImage::Format_RGB32);
|
QImage image(40, 30, QImage::Format_RGB32);
|
||||||
image.fill(Qt::green);
|
image.fill(Qt::green);
|
||||||
for (int i=0; i<10; ++i)
|
for (int i=0; i<10; ++i)
|
||||||
xlsx.insertImage(10*i, 5, image);
|
{
|
||||||
|
int index = xlsx.insertImage( 10*i, 5, image );
|
||||||
|
qDebug() << " [image index] " << index;
|
||||||
|
}
|
||||||
xlsx.saveAs("image1.xlsx");
|
xlsx.saveAs("image1.xlsx");
|
||||||
|
|
||||||
QXlsx::Document xlsx2("image1.xlsx");
|
QXlsx::Document xlsx2("image1.xlsx");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user