xlsxzipwriter.cpp 916 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // xlsxzipwriter.cpp
  2. #include "xlsxzipwriter_p.h"
  3. #include <QtGlobal>
  4. #include <QDebug>
  5. #include <private/qzipwriter_p.h>
  6. QT_BEGIN_NAMESPACE_XLSX
  7. ZipWriter::ZipWriter(const QString &filePath)
  8. {
  9. m_writer = new QZipWriter(filePath, QIODevice::WriteOnly);
  10. m_writer->setCompressionPolicy(QZipWriter::AutoCompress);
  11. }
  12. ZipWriter::ZipWriter(QIODevice *device)
  13. {
  14. m_writer = new QZipWriter(device);
  15. m_writer->setCompressionPolicy(QZipWriter::AutoCompress);
  16. }
  17. ZipWriter::~ZipWriter()
  18. {
  19. delete m_writer;
  20. }
  21. bool ZipWriter::error() const
  22. {
  23. return m_writer->status() != QZipWriter::NoError;
  24. }
  25. void ZipWriter::addFile(const QString &filePath, QIODevice *device)
  26. {
  27. m_writer->addFile(filePath, device);
  28. }
  29. void ZipWriter::addFile(const QString &filePath, const QByteArray &data)
  30. {
  31. m_writer->addFile(filePath, data);
  32. }
  33. void ZipWriter::close()
  34. {
  35. m_writer->close();
  36. }
  37. QT_END_NAMESPACE_XLSX