diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index 8e394ad73146..2dab16be5e87 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -53,6 +53,10 @@ #include #include #include +#include +#include +#include +#include #include using namespace oox; @@ -861,6 +865,28 @@ void ExcDocument::WriteXml( XclExpXmlStream& rStrm ) { InitializeSave(); + auto* pDrawLayer = GetDoc().GetDrawLayer(); + if (pDrawLayer) + { + SdrPage* pPage = pDrawLayer->GetPage(0); + if (pPage) + { + std::shared_ptr pTheme = pPage->getSdrPageProperties().GetTheme(); + if (pTheme) + { + OUString sThemeRelationshipPath = "theme/theme1.xml"; + OUString sThemeDocumentPath = "xl/" + sThemeRelationshipPath; + + oox::ThemeExport aThemeExport(&rStrm, oox::drawingml::DOCUMENT_XLSX); + aThemeExport.write(sThemeDocumentPath, *pTheme); + + rStrm.addRelation(rStrm.GetCurrentStream()->getOutputStream(), + oox::getRelationship(Relationship::THEME), + sThemeRelationshipPath); + } + } + } + aHeader.WriteXml( rStrm ); for( size_t nTab = 0, nTabCount = maTableList.GetSize(); nTab < nTabCount; ++nTab ) diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx index 076dbe24b63f..2f99a49d595e 100644 --- a/sc/source/filter/oox/workbookfragment.cxx +++ b/sc/source/filter/oox/workbookfragment.cxx @@ -64,6 +64,7 @@ #include #include +#include #include #include #include @@ -486,6 +487,12 @@ void WorkbookFragment::finalizeImport() // load all worksheets importSheetFragments(*this, aSheetFragments); + SdrPage* pPage = pModel->GetPage(0); + if (pPage && pTheme && !pTheme->GetName().isEmpty()) + { + pPage->getSdrPageProperties().SetTheme(pTheme); + } + // assumes getTables().finalizeImport ( which creates the DatabaseRanges ) // has been called already getTables().applyAutoFilters(); @@ -512,6 +519,7 @@ void WorkbookFragment::finalizeImport() rxSheetGlob.reset(); } + getDocImport().finalize(); recalcFormulaCells();