1
0
mirror of https://github.com/QtExcel/QXlsx.git synced 2025-02-06 05:08:22 +08:00

Merge pull request #248 from liufeijin/patch-2

Update xlsxdocument.cpp 
- to alpha branch
This commit is contained in:
Jay Two 2023-01-04 15:29:33 +09:00 committed by GitHub
commit 1985a3eed3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1212,6 +1212,17 @@ bool Document::selectSheet(const QString &name)
bool Document::selectSheet(int index)
{
Q_D(Document);
// after selected sheet for writing or reading, many sheets of the excel are be set to selected
// i can't find where is the bug, so make circle loop to set only one worksheet is selected other sheets are unselected.
for(int i=0;i<d->workbook->sheetCount();i++){ // liu feij 2022-10-15 to avoid many sheet are selected , only the activesheet is selected
if(d->workbook->sheet(i)->sheetType()==AbstractSheet::ST_WorkSheet){
if(d->workbook->sheet(i)->sheetName()==name){
static_cast<Worksheet *>(d->workbook->sheet(i))->setSelected(true);
}else{
static_cast<Worksheet *>(d->workbook->sheet(i))->setSelected(false);
}
}
}
return d->workbook->setActiveSheet(index);
}