Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write sheetFormatProps #302

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions QXlsx/header/xlsxutility_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ QT_BEGIN_NAMESPACE_XLSX
class CellReference;

bool parseXsdBoolean(const QString &value, bool defaultValue = false);
QString xsdBoolean(bool value);

QStringList splitPath(const QString &path);
QString getRelFilePath(const QString &filePath);
Expand Down
7 changes: 0 additions & 7 deletions QXlsx/header/xlsxworksheet_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,11 @@ class WorksheetPrivate : public AbstractSheetPrivate
QMap<int, CellFormula> sharedFormulaMap; // shared formula map

CellRange dimension;
int previous_row;

mutable QMap<int, QString> row_spans;
QMap<int, double> row_sizes;
QMap<int, double> col_sizes;

int outline_row_level;
int outline_col_level;

int default_row_height;
bool default_row_zeroed;

// pagesetup and print settings add by liufeijin 20181028, liufeijin
QString PpaperSize;
QString Pscale;
Expand Down
5 changes: 5 additions & 0 deletions QXlsx/source/xlsxutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,9 @@ QString convertSharedFormula(const QString &rootFormula,
return result.join(QString());
}

QString xsdBoolean(bool value)
{
return value ? QStringLiteral("1") : QStringLiteral("0");
}

QT_END_NAMESPACE_XLSX
34 changes: 12 additions & 22 deletions QXlsx/source/xlsxworksheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ WorksheetPrivate::WorksheetPrivate(Worksheet *p, Worksheet::CreateFlag flag)
, showWhiteSpace(true)
, urlPattern(QStringLiteral("^([fh]tt?ps?://)|(mailto:)|(file://)"))
{
previous_row = 0;

outline_row_level = 0;
outline_col_level = 0;

default_row_height = 15;
default_row_zeroed = false;
}

WorksheetPrivate::~WorksheetPrivate() {}
Expand Down Expand Up @@ -548,7 +541,7 @@ QVariant Worksheet::read(int row, int column) const
Cell *Worksheet::cellAt(const CellReference &row_column) const
{
if (!row_column.isValid())
return 0;
return nullptr;

return cellAt(row_column.row(), row_column.column());
}
Expand All @@ -562,9 +555,9 @@ Cell *Worksheet::cellAt(int row, int col) const
Q_D(const Worksheet);
auto it = d->cellTable.constFind(row);
if (it == d->cellTable.constEnd())
return 0;
return nullptr;
if (!it->contains(col))
return 0;
return nullptr;

return (*it)[col].get();
}
Expand Down Expand Up @@ -1324,17 +1317,14 @@ void Worksheet::saveToXmlFile(QIODevice *device) const

writer.writeStartElement(QStringLiteral("sheetFormatPr"));
writer.writeAttribute(QStringLiteral("defaultRowHeight"),
QString::number(d->default_row_height));
if (d->default_row_height != 15)
writer.writeAttribute(QStringLiteral("customHeight"), QStringLiteral("1"));
if (d->default_row_zeroed)
writer.writeAttribute(QStringLiteral("zeroHeight"), QStringLiteral("1"));
if (d->outline_row_level)
writer.writeAttribute(QStringLiteral("outlineLevelRow"),
QString::number(d->outline_row_level));
if (d->outline_col_level)
writer.writeAttribute(QStringLiteral("outlineLevelCol"),
QString::number(d->outline_col_level));
QString::number(d->sheetFormatProps.defaultRowHeight));
writer.writeAttribute(QStringLiteral("customHeight"),
xsdBoolean(d->sheetFormatProps.customHeight));
writer.writeAttribute(QStringLiteral("zeroHeight"), xsdBoolean(d->sheetFormatProps.zeroHeight));
writer.writeAttribute(QStringLiteral("outlineLevelRow"),
QString::number(d->sheetFormatProps.outlineLevelRow));
writer.writeAttribute(QStringLiteral("outlineLevelCol"),
QString::number(d->sheetFormatProps.outlineLevelCol));
// for Excel 2010
// writer.writeAttribute("x14ac:dyDescent", "0.25");
writer.writeEndElement(); // sheetFormatPr
Expand Down Expand Up @@ -2232,7 +2222,7 @@ int WorksheetPrivate::rowPixelsSize(int row) const
if (it != row_sizes.constEnd())
height = it.value();
else
height = default_row_height;
height = sheetFormatProps.defaultRowHeight;
return static_cast<int>(4.0 / 3.0 * height);
}

Expand Down
Loading