Skip to content
Open
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
38 changes: 3 additions & 35 deletions QXlsx/source/xlsxworksheet.cpp

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DNM
TBH this is a bad MR
why use XmlData to do a copy work?

Original file line number Diff line number Diff line change
Expand Up @@ -193,42 +193,10 @@ Worksheet::Worksheet(const QString &name, int id, Workbook *workbook, CreateFlag
Worksheet *Worksheet::copy(const QString &distName, int distId) const
{
Q_D(const Worksheet);
auto sheet = new Worksheet(distName, distId, d->workbook, F_NewFromScratch);
WorksheetPrivate *sheet_d = sheet->d_func();

sheet_d->dimension = d->dimension;

for (auto it = d->cellTable.cells.begin(); it != d->cellTable.cells.end(); ++it) {
int row = it.key();
for (auto it2 = it.value().begin(); it2 != it.value().end(); ++it2) {
int col = it2.key();

auto cell = std::make_shared<Cell>(it2.value().get());
cell->d_ptr->parent = sheet;

if (cell->cellType() == Cell::SharedStringType)
d->workbook->sharedStrings()->addSharedString(cell->d_ptr->richString);

sheet_d->cellTable.setValue(row, col, cell);
}
}

// for (auto it = d->cellTable.cells.begin(); it != d->cellTable.cells.end(); ++it) {
// auto cell = std::make_shared<Cell>(it.value().get());
// cell->d_ptr->parent = sheet;

// if (cell->cellType() == Cell::SharedStringType)
// d->workbook->sharedStrings()->addSharedString(cell->d_ptr->richString);

// sheet_d->cellTable.setValue(CellTable::row(it.key()), CellTable::column(it.key()), cell);
// }

sheet_d->merges = d->merges;
// sheet_d->rowsInfo = d->rowsInfo;
// sheet_d->colsInfo = d->colsInfo;
// sheet_d->colsInfoHelper = d->colsInfoHelper;
// sheet_d->dataValidationsList = d->dataValidationsList;
// sheet_d->conditionalFormattingList = d->conditionalFormattingList;
auto srcSheetData = saveToXmlData();
auto sheet = new Worksheet(distName, distId, d->workbook, F_NewFromScratch);
sheet->loadFromXmlData(srcSheetData);

return sheet;
}
Expand Down