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

Update .gitignore and freeze row or col #352

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ QXlsx/debug/*
QXlsx/release/*
*.-1
*.pro.user
build-*/
build*/
/build-*/*

# visual studio
Expand Down
3 changes: 3 additions & 0 deletions QXlsx/header/xlsxabstractsheet_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class AbstractSheetPrivate : public AbstractOOXmlFilePrivate
int id;
AbstractSheet::SheetState sheetState;
AbstractSheet::SheetType type;

int frozen_rows{};
int frozen_cols{};
};

QT_END_NAMESPACE_XLSX
Expand Down
2 changes: 2 additions & 0 deletions QXlsx/header/xlsxworksheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class QXLSX_EXPORT Worksheet : public AbstractSheet
bool isWhiteSpaceVisible() const;
void setWhiteSpaceVisible(bool visible);
bool setStartPage(int spagen); // add by liufeijin20181028
void setFrozenRows(int rows);
void setFrozenColumns(int cols);

QVector<CellLocation> getFullCells(int *maxRow, int *maxCol);

Expand Down
25 changes: 25 additions & 0 deletions QXlsx/source/xlsxworksheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,17 @@ void Worksheet::saveToXmlFile(QIODevice *device) const
if (!d->showWhiteSpace)
writer.writeAttribute(QStringLiteral("showWhiteSpace"), QStringLiteral("0"));
writer.writeAttribute(QStringLiteral("workbookViewId"), QStringLiteral("0"));
if ((d->frozen_cols > 0) || (d->frozen_rows > 0)) {
writer.writeStartElement(QStringLiteral("pane"));
if (d->frozen_cols > 0)
writer.writeAttribute(QStringLiteral("xSplit"), QString::number(d->frozen_cols)); // set count of fixed col
if (d->frozen_rows > 0)
writer.writeAttribute(QStringLiteral("ySplit"), QString::number(d->frozen_rows)); // set count of fixed row
writer.writeAttribute(QStringLiteral("topLeftCell"), CellReference(d->frozen_rows + 1, d->frozen_cols + 1).toString()); //set next after fixed area cell
writer.writeAttribute(QStringLiteral("activePane"), QStringLiteral("bottomRight"));
writer.writeAttribute(QStringLiteral("state"), QStringLiteral("frozenSplit"));
writer.writeEndElement(); // pane
}
writer.writeEndElement(); // sheetView
writer.writeEndElement(); // sheetViews

Expand Down Expand Up @@ -1474,6 +1485,20 @@ bool Worksheet::setStartPage(int spagen)
}
//}}

void Worksheet::setFrozenRows(int rows)
{
Q_D(Worksheet);

d->frozen_rows=rows;
}

void Worksheet::setFrozenColumns(int cols)
{
Q_D(Worksheet);

d->frozen_cols=cols;
}

void WorksheetPrivate::saveXmlSheetData(QXmlStreamWriter &writer) const
{
calculateSpans();
Expand Down
Loading