Add overload function for setRow and setColumn

This commit is contained in:
Debao Zhang
2013-10-31 12:19:48 +08:00
parent 93e1661aac
commit 27c0029df1
7 changed files with 94 additions and 20 deletions
+18
View File
@@ -129,6 +129,24 @@ QString xl_col_to_name(int col_num)
return col_str;
}
int xl_col_name_to_value(const QString &col_str)
{
QRegularExpression re(QStringLiteral("^([A-Z]{1,3})$"));
QRegularExpressionMatch match = re.match(col_str);
if (match.hasMatch()) {
int col = 0;
int expn = 0;
for (int i=col_str.size()-1; i>-1; --i) {
col += (col_str[i].unicode() - 'A' + 1) * intPow(26, expn);
expn++;
}
col--;
return col;
}
return -1;
}
QString xl_rowcol_to_cell(int row, int col, bool row_abs, bool col_abs)
{
row += 1; //Change to 1-index