From c83da367a9cc0b24a59633542e36a54d86df95db Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 19 Nov 2019 23:04:04 +0300 Subject: [PATCH] xlsx exporter has been added --- common.pri | 1 + include/lrpreviewreportwidget.h | 1 + limereport/exporters/lrexcelexporter.cpp | 268 +++++++++++++++++++++++ limereport/exporters/lrexcelexporter.h | 49 +++++ limereport/images/excel_export.png | Bin 0 -> 2937 bytes limereport/limereport.pri | 18 +- limereport/limereport.pro | 9 +- limereport/lrfactoryinitializer.cpp | 18 ++ limereport/lrpreviewreportwidget.cpp | 10 + limereport/lrpreviewreportwidget.h | 1 + limereport/lrpreviewreportwindow.cpp | 5 + limereport/lrpreviewreportwindow.h | 1 + limereport/lrpreviewreportwindow.ui | 35 ++- limereport/report.qrc | 1 + 14 files changed, 406 insertions(+), 11 deletions(-) create mode 100644 limereport/exporters/lrexcelexporter.cpp create mode 100644 limereport/exporters/lrexcelexporter.h create mode 100644 limereport/images/excel_export.png diff --git a/common.pri b/common.pri index 78767ea..51eaa28 100644 --- a/common.pri +++ b/common.pri @@ -1,4 +1,5 @@ #BINARY_RESULT_DIR = $${TOP_BUILD_DIR} +CONFIG *= qtxlsx isEmpty(BINARY_RESULT_DIR) { BINARY_RESULT_DIR = $${PWD} diff --git a/include/lrpreviewreportwidget.h b/include/lrpreviewreportwidget.h index 1e24e9b..1315962 100644 --- a/include/lrpreviewreportwidget.h +++ b/include/lrpreviewreportwidget.h @@ -53,6 +53,7 @@ public slots: void print(); void printToPDF(); + void printToExcel(); void pageNavigatorChanged(int value); void saveToFile(); void setScalePercent(int percent); diff --git a/limereport/exporters/lrexcelexporter.cpp b/limereport/exporters/lrexcelexporter.cpp new file mode 100644 index 0000000..2fda35c --- /dev/null +++ b/limereport/exporters/lrexcelexporter.cpp @@ -0,0 +1,268 @@ +#include "lrexcelexporter.h" +#include "lrtextitem.h" +#include "lrimageitem.h" +#include "lrshapeitem.h" +#include "lrexportersfactory.h" +#include "lrreportengine_p.h" + +namespace{ + +LimeReport::ReportExporterInterface* createExcelExporter(LimeReport::ReportEnginePrivate* parent){ + return new LimeReport::ExcelExporter(parent); +} + +bool VARIABLE_IS_NOT_USED registred = LimeReport::ExportersFactory::instance().registerCreator("XLSX", LimeReport::ExporterAttribs(QObject::tr("Export to xlsx"), "XLSXExporter"), createExcelExporter); + +} + +namespace LimeReport{ + +ExcelExporter::ExcelExporter(ReportEnginePrivate *parent) + :QObject(parent) +{ + exportedTypes << "ImageItem" << "TextItem"; +} + +QString ExcelExporter::exporterName() +{ + return QObject::tr("XLSX"); +} + +QString ExcelExporter::exporterFileExt() +{ + return "xlsx"; +} + +QString ExcelExporter::hint() +{ + return QObject::tr("Export report to xlsx"); +} + +bool ExcelExporter::exportPages(ReportPages pages, const QString &fileName, const QMap ¶ms) +{ + + double xSizeFactor = params["xSizeFactor"].isNull() ? 2 : params["xSizeFactor"].toDouble(); + double ySizeFactor = params["ySizeFactor"].isNull() ? 0.37 : params["ySizeFactor"].toDouble(); + + if (pages.isEmpty()) return false; + + m_document = new QXlsx::Document(); + + x.clear(); + y.clear(); + + Grid grid; + + if ((pages.size() > 1) && (pages[0]->pos() == pages[1]->pos()) ){ + int curHeight = 0; + foreach(PageItemDesignIntf::Ptr pageItem, pages){ + pageItem->setPos(0,curHeight); + curHeight+=pageItem->height(); + } + } + + foreach(PageItemDesignIntf::Ptr page, pages){ + buildGrid(&grid,page.data()); + } + + foreach (qreal value, grid.x.values()) { + x.append(value); + } + + foreach (qreal value, grid.y.values()) { + y.append(value); + } + + std::sort(x.begin(), x.end()); + std::sort(y.begin(), y.end()); + + m_yOffset = 0; + m_xOffset = 0; + + m_document->setTopPageMargin(pages.first()->topMargin()/25.4); + m_document->setLeftPageMargin(pages.first()->leftMargin()/25.4); + m_document->setRightPageMargin(pages.first()->rightMargin()/25.4); + m_document->setBottomPageMargin(pages.first()->bottomMargin()/25.4); + + for(int i = 0; i 0){ + qreal columnWidth = x[i] - pages.at(0)->leftMargin(); + if (columnWidth>0){ + m_document->setColumnWidth(i+1, columnWidth / xSizeFactor); + m_xOffset = 1; + } + } + } else { + m_document->setColumnWidth(i+1, (x[i]-x[i-1]) / xSizeFactor); + } + } + + for(int i = 0; i 0){ + qreal rowHeight = y[i] - pages.at(0)->topMargin(); + if (rowHeight > 0){ + m_document->setRowHeight(i+1, rowHeight / ySizeFactor); + m_yOffset = 1; + } + } + } else { + m_document->setRowHeight(i+1, (y[i]-y[i-1]) / ySizeFactor); + } + } + + foreach(PageItemDesignIntf::Ptr page, pages){ + exportItem(page.data()); + } + + + return m_document->saveAs(fileName); +} + +void ExcelExporter::buildGrid(Grid *grid, BaseDesignIntf *item) +{ + foreach (BaseDesignIntf* child, item->childBaseItems()) { + if (child->canContainChildren()) + buildGrid(grid, child); + else{ + if (exportedTypes.contains(child->storageTypeName())){ + grid->x.insert(child->getAbsolutePosX()); + grid->x.insert(child->getAbsolutePosX()+child->getItemWidth()); + grid->y.insert(child->getAbsolutePosY()); + grid->y.insert(child->getAbsolutePosY()+child->getItemHeight()); + } + } + } + +} + +void ExcelExporter::exportItem(BaseDesignIntf *item) +{ + if (item->canContainChildren()){ + foreach (BaseDesignIntf* child, item->childBaseItems()){ + exportItem(child); + } + } else { + createItemCell(item); + } +} + +QXlsx::Format ExcelExporter::createTextItemFormat(BaseDesignIntf* item){ + TextItem* textItem = dynamic_cast(item); + QXlsx::Format format; + format.setTextWarp(true); +// format.setFontName(item->font().family()); +// format.setFontBold(item->font().bold()); +// format.setFontItalic(item->font().italic()); +// format.setFontUnderline(item->font().underline() ? QXlsx::Format::FontUnderlineSingle : QXlsx::Format::FontUnderlineNone); +// format.setFontSize(item->font().pointSize()); + format.setFont(item->font()); +// format.setFontSize(item->font().pointSize()-1); + format.setFontColor(item->fontColor()); + format.setFillPattern(QXlsx::Format::PatternSolid); + format.setPatternBackgroundColor(item->backgroundColor()); + format.setBorderColor(item->borderColor()); + + if (item->borderLines() & BaseDesignIntf::TopLine){ + format.setTopBorderStyle(QXlsx::Format::BorderThin); + } + if (item->borderLines() & BaseDesignIntf::RightLine){ + format.setRightBorderStyle(QXlsx::Format::BorderThin); + } + if (item->borderLines() & BaseDesignIntf::LeftLine){ + format.setLeftBorderStyle(QXlsx::Format::BorderThin); + } + if (item->borderLines() & BaseDesignIntf::BottomLine){ + format.setBottomBorderStyle(QXlsx::Format::BorderThin); + } + + if (textItem->alignment() & Qt::AlignLeft){ + format.setHorizontalAlignment(QXlsx::Format::AlignLeft); + } + if (textItem->alignment() & Qt::AlignRight){ + format.setHorizontalAlignment(QXlsx::Format::AlignRight); + } + if (textItem->alignment() & Qt::AlignHCenter){ + format.setHorizontalAlignment(QXlsx::Format::AlignHCenter); + } + if (textItem->alignment() & Qt::AlignTop){ + format.setVerticalAlignment(QXlsx::Format::AlignTop); + } + if (textItem->alignment() & Qt::AlignBottom){ + format.setVerticalAlignment(QXlsx::Format::AlignBottom); + } + if (textItem->alignment() & Qt::AlignVCenter){ + format.setVerticalAlignment(QXlsx::Format::AlignVCenter); + } + + return format; +} + + +void ExcelExporter::createItemCell(BaseDesignIntf *item) +{ + int startColumnIndex = cellStartColumnIndex(item); + int endColumnIndex = cellEndColumnIndex(item); + int startRowIndex = cellStartRowIndex(item); + int endRowIndex = cellEndRowIndex(item); + bool needMerge = (endColumnIndex - startColumnIndex > 1) || (endRowIndex - startRowIndex > 1); + + QXlsx::Format format; + + if (item->storageTypeName().compare("TextItem") == 0){ + TextItem* ci = dynamic_cast(item); + format = createTextItemFormat(item); + m_document->write(startRowIndex, startColumnIndex, ci->content(), format); + if (needMerge) + m_document->mergeCells(QXlsx::CellRange(startRowIndex, startColumnIndex, endRowIndex-1, endColumnIndex-1), format); + } else if (item->storageTypeName().compare("ImageItem") == 0){ + LimeReport::ImageItem* ii = dynamic_cast(item); + QImage img = ii->image().scaled(item->width()/3,item->height()/3, Qt::KeepAspectRatio); + m_document->insertImage(startRowIndex-1, startColumnIndex, img); + if (needMerge) + m_document->mergeCells(QXlsx::CellRange(startRowIndex, startColumnIndex, endRowIndex-1, endColumnIndex-1), format); + } else { + //m_document->write(startRowIndex, startColumnIndex, item->objectName()); + } + + +} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wfloat-equal" + +int ExcelExporter::cellStartColumnIndex(BaseDesignIntf *item) +{ + for(int i = 1; i <= x.size(); ++i){ + if (x[i-1] == item->getAbsolutePosX()) return i + m_xOffset; + } + return -1; +} + +int ExcelExporter::cellEndColumnIndex(BaseDesignIntf *item) +{ + for(int i = 1; i <= x.size(); ++i){ + if (x[i-1] == (item->getAbsolutePosX() + item->getItemWidth()) ) return i + m_xOffset; + } + return -1; +} + +int ExcelExporter::cellStartRowIndex(BaseDesignIntf *item) +{ + for(int i = 1; i <= y.size(); ++i){ + if (y[i-1] == item->getAbsolutePosY()) return i + m_yOffset; + } + return -1; +} + +int ExcelExporter::cellEndRowIndex(BaseDesignIntf *item) +{ + for(int i = 1; i <= y.size(); ++i){ + if (y[i-1] == (item->getAbsolutePosY() + item->getItemHeight()) ) return i + m_yOffset; + } + return -1; +} + +#pragma clang diagnostic pop +} //namespace LimeReport diff --git a/limereport/exporters/lrexcelexporter.h b/limereport/exporters/lrexcelexporter.h new file mode 100644 index 0000000..abdf472 --- /dev/null +++ b/limereport/exporters/lrexcelexporter.h @@ -0,0 +1,49 @@ +#ifndef LREXCELEXPORTER_H +#define LREXCELEXPORTER_H + +#include +#include +#include "lrexporterintf.h" + + +namespace LimeReport{ + +struct Grid{ + QSet x; + QSet y; +}; + +class ExcelExporter : public QObject, public ReportExporterInterface{ + Q_OBJECT +public: + ExcelExporter(ReportEnginePrivate *parent = 0); + // IReportExporter interface + QString exporterName(); + QString exporterFileExt(); + QString hint(); + bool exportPages(ReportPages pages, const QString& fileName, const QMap& params = QMap()); +private: + void buildGrid(Grid* grid, BaseDesignIntf* item); + void exportItem(BaseDesignIntf* item); + void createItemCell(BaseDesignIntf* item); + int cellStartColumnIndex(BaseDesignIntf* item); + int cellEndColumnIndex(BaseDesignIntf* item); + int cellStartRowIndex(BaseDesignIntf* item); + int cellEndRowIndex(BaseDesignIntf* item); + QXlsx::Format createTextItemFormat(BaseDesignIntf *item); +private: + + QVectorx; + QVectory; + QVector exportedTypes; + + int m_xOffset; + int m_yOffset; + + QXlsx::Document* m_document; + +}; + +} //namespace LimeReport + +#endif // LREXCELEXPORTER_H diff --git a/limereport/images/excel_export.png b/limereport/images/excel_export.png new file mode 100644 index 0000000000000000000000000000000000000000..b279a686de941db739ab13351cc79ccd76759c1b GIT binary patch literal 2937 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 literal 0 HcmV?d00001 diff --git a/limereport/limereport.pri b/limereport/limereport.pri index 0918890..95c6ea5 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -1,5 +1,10 @@ include(../common.pri) +contains(CONFIG, qtxlsx){ + DEFINES += HAVE_QTXLSX + include($$PWD/../3rdparty/qtxlsx/src/xlsx/qtxlsx.pri) +} + contains(CONFIG, embedded_designer){ include(designer.pri) } @@ -69,9 +74,9 @@ SOURCES += \ $$REPORT_PATH/items/lrchartitemeditor.cpp \ $$REPORT_PATH/lrreporttranslation.cpp \ $$REPORT_PATH/exporters/lrpdfexporter.cpp \ + $$REPORT_PATH/exporters/lrhtmlexporter.cpp \ $$REPORT_PATH/lrpreparedpages.cpp - contains(CONFIG, staticlib){ SOURCES += $$REPORT_PATH/lrfactoryinitializer.cpp } @@ -80,6 +85,11 @@ contains(CONFIG, zint){ SOURCES += $$REPORT_PATH/items/lrbarcodeitem.cpp } +contains(CONFIG, qtxlsx){ + message(QtXLSX) + SOURCES += $$REPORT_PATH/exporters/lrexcelexporter.cpp +} + HEADERS += \ $$REPORT_PATH/base/lrsingleton.h \ $$REPORT_PATH/base/lrsimpleabstractfactory.h \ @@ -154,10 +164,10 @@ HEADERS += \ $$REPORT_PATH/lrexporterintf.h \ $$REPORT_PATH/lrexportersfactory.h \ $$REPORT_PATH/exporters/lrpdfexporter.h \ + $$REPORT_PATH/exporters/lrhtmlexporter.h \ $$REPORT_PATH/lrpreparedpages.h \ $$REPORT_PATH/lrpreparedpagesintf.h - contains(CONFIG, staticlib){ HEADERS += $$REPORT_PATH/lrfactoryinitializer.h } @@ -166,6 +176,10 @@ contains(CONFIG,zint){ HEADERS += $$REPORT_PATH/items/lrbarcodeitem.h } +contains(CONFIG, qtxlsx){ + HEADERS += $$REPORT_PATH/exporters/lrexcelexporter.h +} + FORMS += \ $$REPORT_PATH/lrpreviewreportwindow.ui \ $$REPORT_PATH/lrpreviewreportwidget.ui \ diff --git a/limereport/limereport.pro b/limereport/limereport.pro index d1ac03d..f790982 100644 --- a/limereport/limereport.pro +++ b/limereport/limereport.pro @@ -40,8 +40,7 @@ EXTRA_FILES += \ $$PWD/lrscriptenginemanagerintf.h \ $$PWD/lrcallbackdatasourceintf.h \ $$PWD/lrpreviewreportwidget.h \ - $$PWD/lrreportdesignwindowintrerface.h \ - $$PWD/lrpreparedpagesintf.h + $$PWD/lrreportdesignwindowintrerface.h include(limereport.pri) @@ -112,14 +111,14 @@ INSTALLS += target ####Automatically build required translation files (*.qm) contains(CONFIG,build_translations){ - LANGUAGES = ru es ar fr zh pl + LANGUAGES = ru es_ES ar fr zh defineReplace(prependAll) { for(a,$$1):result += $$2$${a}$$3 return($$result) } - TRANSLATIONS = $$prependAll(LANGUAGES, $$TRANSLATIONS_PATH/limereport_,.ts) + TRANSLATIONS = $$prependAll(LANGUAGES, \"$$TRANSLATIONS_PATH/limereport_,.ts\") qtPrepareTool(LUPDATE, lupdate) @@ -133,7 +132,7 @@ lessThan(QT_MAJOR_VERSION, 5){ qtPrepareTool(LRELEASE, lrelease) for(tsfile, TRANSLATIONS) { qmfile = $$tsfile - qmfile ~= s,".ts$",".qm", + qmfile ~= s,".ts\"$",".qm\"", qm.commands += $$LRELEASE -removeidentical $$tsfile -qm $$qmfile $$escape_expand(\\n\\t) tmp_command = $$LRELEASE -removeidentical $$tsfile -qm $$qmfile $$escape_expand(\\n\\t) TRANSLATIONS_FILES += $$qmfile diff --git a/limereport/lrfactoryinitializer.cpp b/limereport/lrfactoryinitializer.cpp index f244d1a..672ee82 100644 --- a/limereport/lrfactoryinitializer.cpp +++ b/limereport/lrfactoryinitializer.cpp @@ -45,6 +45,10 @@ #include "lrexporterintf.h" #include "exporters/lrpdfexporter.h" +#ifdef HAVE_QTXLSX +#include "exporters/lrexcelexporter.h" +#endif + void initResources(){ Q_INIT_RESOURCE(report); #ifdef HAVE_REPORT_DESIGNER @@ -450,6 +454,12 @@ LimeReport::ReportExporterInterface* createPDFExporter(ReportEnginePrivate* pare return new LimeReport::PDFExporter(parent); } +#ifdef HAVE_QTXLSX +LimeReport::ReportExporterInterface* createExcelExporter(ReportEnginePrivate* parent){ + return new LimeReport::ExcelExporter(parent); +} +#endif + void initExporters() { ExportersFactory::instance().registerCreator( @@ -457,6 +467,14 @@ void initExporters() LimeReport::ExporterAttribs(QObject::tr("Export to PDF"), "PDFExporter"), createPDFExporter ); + +#ifdef HAVE_QTXLSX + ExportersFactory::instance().registerCreator( + "XLSX", + LimeReport::ExporterAttribs(QObject::tr("Export to xlsx"),"ExcelExporter"), + createExcelExporter + ); +#endif } } //namespace LimeReport diff --git a/limereport/lrpreviewreportwidget.cpp b/limereport/lrpreviewreportwidget.cpp index 87a3bab..d660314 100644 --- a/limereport/lrpreviewreportwidget.cpp +++ b/limereport/lrpreviewreportwidget.cpp @@ -258,6 +258,16 @@ void PreviewReportWidget::print() } +void PreviewReportWidget::printToExcel() +{ + if (!d_ptr->m_reportPages.isEmpty()){ + exportReport("XLSX"); + foreach(PageItemDesignIntf::Ptr pageItem, d_ptr->m_reportPages){ + d_ptr->m_previewPage->reactivatePageItem(pageItem); + } + } +} + void PreviewReportWidget::printToPDF() { if (!d_ptr->m_reportPages.isEmpty()){ diff --git a/limereport/lrpreviewreportwidget.h b/limereport/lrpreviewreportwidget.h index 1e24e9b..1315962 100644 --- a/limereport/lrpreviewreportwidget.h +++ b/limereport/lrpreviewreportwidget.h @@ -53,6 +53,7 @@ public slots: void print(); void printToPDF(); + void printToExcel(); void pageNavigatorChanged(int value); void saveToFile(); void setScalePercent(int percent); diff --git a/limereport/lrpreviewreportwindow.cpp b/limereport/lrpreviewreportwindow.cpp index 01d42cb..6517b78 100644 --- a/limereport/lrpreviewreportwindow.cpp +++ b/limereport/lrpreviewreportwindow.cpp @@ -468,6 +468,11 @@ void PreviewReportWindow::slotPrintToPDF() m_previewReportWidget->printToPDF(); } +void PreviewReportWindow::slotPrintToExcel() +{ + m_previewReportWidget->printToExcel(); +} + void PreviewReportWindow::slotPageChanged(int pageIndex) { m_pagesNavigator->setValue(pageIndex); diff --git a/limereport/lrpreviewreportwindow.h b/limereport/lrpreviewreportwindow.h index 98808a3..af3a7fe 100644 --- a/limereport/lrpreviewreportwindow.h +++ b/limereport/lrpreviewreportwindow.h @@ -105,6 +105,7 @@ public slots: void slotFirstPage(); void slotLastPage(); void slotPrintToPDF(); + void slotPrintToExcel(); void slotPageChanged(int pageIndex); void slotInsertNewTextItem(); void slotActivateItemSelectionMode(); diff --git a/limereport/lrpreviewreportwindow.ui b/limereport/lrpreviewreportwindow.ui index 3db023f..44fb1fa 100644 --- a/limereport/lrpreviewreportwindow.ui +++ b/limereport/lrpreviewreportwindow.ui @@ -35,7 +35,7 @@ 0 0 800 - 20 + 22 @@ -78,6 +78,7 @@ + @@ -339,14 +340,23 @@ Del + + + + :/report/images/excel_export.png:/report/images/excel_export.png + + + actionPrintToExcel + + + Export report to Excel + + - - - @@ -541,6 +551,22 @@ + + actionactionPrintToExcel + triggered() + LimeReport::PreviewReportWindow + slotPrintToExcel() + + + -1 + -1 + + + 399 + 299 + + + slotNextPage() @@ -554,5 +580,6 @@ slotInsertNewTextItem() slotActivateItemSelectionMode() slotDeleteSelectedItems() + slotPrintToExcel() diff --git a/limereport/report.qrc b/limereport/report.qrc index 89999d9..b3e9f61 100644 --- a/limereport/report.qrc +++ b/limereport/report.qrc @@ -186,5 +186,6 @@ images/designer.png images/lock.png images/unlock.png + images/excel_export.png