|
|
@ -1611,6 +1611,10 @@ bool Worksheet::setColumn(const QString &colFirst, const QString &colLast, doubl |
|
|
|
return setColumn(col1, col2, width, format, hidden); |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets width in characters of a range of columns. Columns can be specified as "A", "B" ... "Z". |
|
|
|
Returns true on success. |
|
|
|
*/ |
|
|
|
bool Worksheet::setColumnWidth(const QString &colFirst, const QString &colLast, double width) |
|
|
|
{ |
|
|
|
int col1 = xl_col_name_to_value(colFirst); |
|
|
@ -1621,6 +1625,10 @@ bool Worksheet::setColumnWidth(const QString &colFirst, const QString &colLast, |
|
|
|
return setColumnWidth(col1, col2, width); |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets format property of a range of columns. Columns are 1-indexed. |
|
|
|
Returns true on success. |
|
|
|
*/ |
|
|
|
bool Worksheet::setColumnFormat(const QString &colFirst, const QString &colLast, const Format &format) |
|
|
|
{ |
|
|
|
int col1 = xl_col_name_to_value(colFirst); |
|
|
@ -1631,6 +1639,11 @@ bool Worksheet::setColumnFormat(const QString &colFirst, const QString &colLast, |
|
|
|
return setColumnFormat(col1, col2, format); |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets hidden property of a range of columns. Columns are 1-indexed. |
|
|
|
Hidden columns are not visible. |
|
|
|
Returns true on success. |
|
|
|
*/ |
|
|
|
bool Worksheet::setColumnHidden(const QString &colFirst, const QString &colLast, bool hidden) |
|
|
|
{ |
|
|
|
int col1 = xl_col_name_to_value(colFirst); |
|
|
@ -1641,54 +1654,10 @@ bool Worksheet::setColumnHidden(const QString &colFirst, const QString &colLast, |
|
|
|
return setColumnHidden(col1, col2, hidden); |
|
|
|
} |
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > Worksheet::getColumnInfoList(int colFirst, int colLast) |
|
|
|
{ |
|
|
|
Q_D(Worksheet); |
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnsInfoList; |
|
|
|
if(isColumnRangeValid(colFirst,colLast)) |
|
|
|
{ |
|
|
|
QList<int> nodes = getColumnIndexes(colFirst, colLast); |
|
|
|
|
|
|
|
for (int idx = 0; idx < nodes.size(); ++idx) { |
|
|
|
int colStart = nodes[idx]; |
|
|
|
if (d->colsInfo.contains(colStart)) { |
|
|
|
QSharedPointer<XlsxColumnInfo> info = d->colsInfo[colStart]; |
|
|
|
columnsInfoList.append(info); |
|
|
|
} else { |
|
|
|
int colEnd = (idx == nodes.size() - 1) ? colLast : nodes[idx+1] - 1; |
|
|
|
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd)); |
|
|
|
d->colsInfo.insert(colFirst, info); |
|
|
|
columnsInfoList.append(info); |
|
|
|
for (int c = colStart; c <= colEnd; ++c) |
|
|
|
d->colsInfoHelper[c] = info; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return columnsInfoList; |
|
|
|
} |
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > Worksheet::getRowInfoList(int rowFirst, int rowLast) |
|
|
|
{ |
|
|
|
Q_D(Worksheet); |
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList; |
|
|
|
|
|
|
|
int min_col = d->dimension.firstColumn() < 0 ? 0 : d->dimension.firstColumn(); |
|
|
|
|
|
|
|
for(int row = rowFirst; row <= rowLast; ++row) { |
|
|
|
if (d->checkDimensions(row, min_col, false, true)) |
|
|
|
continue; |
|
|
|
|
|
|
|
QSharedPointer<XlsxRowInfo> rowInfo; |
|
|
|
if ((d->rowsInfo[row]).isNull()){ |
|
|
|
d->rowsInfo[row] = QSharedPointer<XlsxRowInfo>(new XlsxRowInfo()); |
|
|
|
} |
|
|
|
rowInfoList.append(d->rowsInfo[row]); |
|
|
|
} |
|
|
|
|
|
|
|
return rowInfoList; |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets width in characters of a range of columns. Columns are 1-indexed. |
|
|
|
Returns true on success. |
|
|
|
*/ |
|
|
|
bool Worksheet::setColumnWidth(int colFirst, int colLast, double width) |
|
|
|
{ |
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(colFirst, colLast); |
|
|
@ -1699,6 +1668,9 @@ bool Worksheet::setColumnWidth(int colFirst, int colLast, double width) |
|
|
|
return (columnInfoList.count() > 0); |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets format property of a range of columns. Columns are 1-indexed. |
|
|
|
*/ |
|
|
|
bool Worksheet::setColumnFormat(int colFirst, int colLast, const Format &format) |
|
|
|
{ |
|
|
|
Q_D(Worksheet); |
|
|
@ -1716,6 +1688,9 @@ bool Worksheet::setColumnFormat(int colFirst, int colLast, const Format &format) |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets hidden property of a range of columns. Columns are 1-indexed. |
|
|
|
*/ |
|
|
|
bool Worksheet::setColumnHidden(int colFirst, int colLast, bool hidden) |
|
|
|
{ |
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(colFirst, colLast); |
|
|
@ -1726,41 +1701,44 @@ bool Worksheet::setColumnHidden(int colFirst, int colLast, bool hidden) |
|
|
|
return (columnInfoList.count() > 0); |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns width of the column in characters of the normal font. Columns are 1-indexed. |
|
|
|
*/ |
|
|
|
double Worksheet::columnWidth(int column) |
|
|
|
{ |
|
|
|
Q_D(Worksheet); |
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(column, column); |
|
|
|
if (columnInfoList.count() == 1) { |
|
|
|
qDebug() << "Whoopie Width"; |
|
|
|
return columnInfoList.at(0)->width ; |
|
|
|
} |
|
|
|
|
|
|
|
qDebug() << "Default Width"; |
|
|
|
return d->sheetFormatProps.defaultColWidth; |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns formatting of the column. Columns are 1-indexed. |
|
|
|
*/ |
|
|
|
Format Worksheet::columnFormat(int column) |
|
|
|
{ |
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(column, column); |
|
|
|
if (columnInfoList.count() == 1) { |
|
|
|
qDebug() << "Whoopie Format"; |
|
|
|
return columnInfoList.at(0)->format; |
|
|
|
} |
|
|
|
|
|
|
|
qDebug() << "Default Format"; |
|
|
|
return Format(); |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if column is hidden. Columns are 1-indexed. |
|
|
|
*/ |
|
|
|
bool Worksheet::isColumnHidden(int column) |
|
|
|
{ |
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(column, column); |
|
|
|
if (columnInfoList.count() == 1) { |
|
|
|
qDebug() << "Whoopie Hidden"; |
|
|
|
return columnInfoList.at(0)->hidden; |
|
|
|
} |
|
|
|
|
|
|
|
qDebug() << "Default Hidden"; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
@ -1771,11 +1749,6 @@ bool Worksheet::isColumnHidden(int column) |
|
|
|
|
|
|
|
Returns true if success. |
|
|
|
*/ |
|
|
|
bool Worksheet::setRow(int row, double height, const Format &format, bool hidden) |
|
|
|
{ |
|
|
|
return setRow(row,row, height, format, hidden); |
|
|
|
} |
|
|
|
|
|
|
|
bool Worksheet::setRow(int rowFirst,int rowLast, double height, const Format &format, bool hidden) |
|
|
|
{ |
|
|
|
Q_D(Worksheet); |
|
|
@ -1791,6 +1764,13 @@ bool Worksheet::setRow(int rowFirst,int rowLast, double height, const Format &fo |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets the \a height of the rows including and between \a rowFirst and \a rowLast. |
|
|
|
Row height measured in point size. |
|
|
|
Rows are 1-indexed. |
|
|
|
|
|
|
|
Returns true if success. |
|
|
|
*/ |
|
|
|
bool Worksheet::setRowHeight(int rowFirst,int rowLast, double height) |
|
|
|
{ |
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList = getRowInfoList(rowFirst,rowLast); |
|
|
@ -1803,6 +1783,12 @@ bool Worksheet::setRowHeight(int rowFirst,int rowLast, double height) |
|
|
|
return rowInfoList.count() > 0; |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets the \a format of the rows including and between \a rowFirst and \a rowLast. |
|
|
|
Rows are 1-indexed. |
|
|
|
|
|
|
|
Returns true if success. |
|
|
|
*/ |
|
|
|
bool Worksheet::setRowFormat(int rowFirst,int rowLast, const Format &format) |
|
|
|
{ |
|
|
|
Q_D(Worksheet); |
|
|
@ -1817,6 +1803,12 @@ bool Worksheet::setRowFormat(int rowFirst,int rowLast, const Format &format) |
|
|
|
return rowInfoList.count() > 0; |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets the \a hidden proeprty of the rows including and between \a rowFirst and \a rowLast. |
|
|
|
Rows are 1-indexed. If hidden is true rows will not be visible. |
|
|
|
|
|
|
|
Returns true if success. |
|
|
|
*/ |
|
|
|
bool Worksheet::setRowHidden(int rowFirst,int rowLast, bool hidden) |
|
|
|
{ |
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList = getRowInfoList(rowFirst,rowLast); |
|
|
@ -1828,6 +1820,9 @@ bool Worksheet::setRowHidden(int rowFirst,int rowLast, bool hidden) |
|
|
|
return rowInfoList.count() > 0; |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns height of \a row in points. |
|
|
|
*/ |
|
|
|
double Worksheet::rowHeight(int row) |
|
|
|
{ |
|
|
|
Q_D(Worksheet); |
|
|
@ -1839,6 +1834,9 @@ double Worksheet::rowHeight(int row) |
|
|
|
return d->rowsInfo[row]->height; |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns format of \a row. |
|
|
|
*/ |
|
|
|
Format Worksheet::rowFormat(int row) |
|
|
|
{ |
|
|
|
Q_D(Worksheet); |
|
|
@ -1850,6 +1848,9 @@ Format Worksheet::rowFormat(int row) |
|
|
|
return d->rowsInfo[row]->format; |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if \a row is hidden. |
|
|
|
*/ |
|
|
|
bool Worksheet::isRowHidden(int row) |
|
|
|
{ |
|
|
|
Q_D(Worksheet); |
|
|
@ -1861,6 +1862,54 @@ bool Worksheet::isRowHidden(int row) |
|
|
|
return d->rowsInfo[row]->hidden; |
|
|
|
} |
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > Worksheet::getColumnInfoList(int colFirst, int colLast) |
|
|
|
{ |
|
|
|
Q_D(Worksheet); |
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnsInfoList; |
|
|
|
if(isColumnRangeValid(colFirst,colLast)) |
|
|
|
{ |
|
|
|
QList<int> nodes = getColumnIndexes(colFirst, colLast); |
|
|
|
|
|
|
|
for (int idx = 0; idx < nodes.size(); ++idx) { |
|
|
|
int colStart = nodes[idx]; |
|
|
|
if (d->colsInfo.contains(colStart)) { |
|
|
|
QSharedPointer<XlsxColumnInfo> info = d->colsInfo[colStart]; |
|
|
|
columnsInfoList.append(info); |
|
|
|
} else { |
|
|
|
int colEnd = (idx == nodes.size() - 1) ? colLast : nodes[idx+1] - 1; |
|
|
|
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd)); |
|
|
|
d->colsInfo.insert(colFirst, info); |
|
|
|
columnsInfoList.append(info); |
|
|
|
for (int c = colStart; c <= colEnd; ++c) |
|
|
|
d->colsInfoHelper[c] = info; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return columnsInfoList; |
|
|
|
} |
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > Worksheet::getRowInfoList(int rowFirst, int rowLast) |
|
|
|
{ |
|
|
|
Q_D(Worksheet); |
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList; |
|
|
|
|
|
|
|
int min_col = d->dimension.firstColumn() < 0 ? 0 : d->dimension.firstColumn(); |
|
|
|
|
|
|
|
for(int row = rowFirst; row <= rowLast; ++row) { |
|
|
|
if (d->checkDimensions(row, min_col, false, true)) |
|
|
|
continue; |
|
|
|
|
|
|
|
QSharedPointer<XlsxRowInfo> rowInfo; |
|
|
|
if ((d->rowsInfo[row]).isNull()){ |
|
|
|
d->rowsInfo[row] = QSharedPointer<XlsxRowInfo>(new XlsxRowInfo()); |
|
|
|
} |
|
|
|
rowInfoList.append(d->rowsInfo[row]); |
|
|
|
} |
|
|
|
|
|
|
|
return rowInfoList; |
|
|
|
} |
|
|
|
|
|
|
|
/*!
|
|
|
|
Groups rows from \a rowFirst to \a rowLast with the given \a collapsed. |
|
|
|
|
|
|
@ -2204,14 +2253,12 @@ void WorksheetPrivate::loadXmlColumnsInfo(QXmlStreamReader &reader) |
|
|
|
//Flag indicating that the column width for the affected column(s) is different from the
|
|
|
|
// default or has been manually set
|
|
|
|
if(colAttrs.hasAttribute(QLatin1String("customWidth"))) { |
|
|
|
info->customWidth = colAttrs.value(QLatin1String("customWidth")) == QLatin1String("1"); |
|
|
|
qDebug() << "Custom width: " << info->customWidth; |
|
|
|
info->customWidth = colAttrs.value(QLatin1String("customWidth")) == QLatin1String("1"); |
|
|
|
} |
|
|
|
//Note, node may have "width" without "customWidth"
|
|
|
|
if (colAttrs.hasAttribute(QLatin1String("width"))) { |
|
|
|
double width = colAttrs.value(QLatin1String("width")).toString().toDouble(); |
|
|
|
info->width = width; |
|
|
|
qDebug() << "Width: " << info->width; |
|
|
|
} |
|
|
|
|
|
|
|
info->hidden = colAttrs.value(QLatin1String("hidden")) == QLatin1String("1"); |
|
|
@ -2384,8 +2431,7 @@ bool Worksheet::loadFromXmlFile(QIODevice *device) |
|
|
|
QXmlStreamReader reader(device); |
|
|
|
while (!reader.atEnd()) { |
|
|
|
reader.readNextStartElement(); |
|
|
|
if (reader.tokenType() == QXmlStreamReader::StartElement) { |
|
|
|
qDebug() << "TOKEN: " << reader.name(); |
|
|
|
if (reader.tokenType() == QXmlStreamReader::StartElement) { |
|
|
|
if (reader.name() == QLatin1String("dimension")) { |
|
|
|
QXmlStreamAttributes attributes = reader.attributes(); |
|
|
|
QString range = attributes.value(QLatin1String("ref")).toString(); |
|
|
|