Copier le thème d un classeur dans un autre

Copier le thème d’un classeur dans un autre

Le code d’exemple suivant montre comment copier un thème d’un classeur dans un autre classeur. Le code est utile pour appliquer des thèmes intégrés ou personnalisés. Créez simplement votre thème souhaité (peut être un thème intégré ou personnalisé) dans votre fichier modèle à l’aide de Microsoft Excel, puis copiez-le dans votre classeur source à l’aide du code suivant.

Code d’exemple

//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
Aspose::Cells::Startup();
//Source directory path
U16String dirPath(u"..\\Data\\TechnicalArticles\\");
//Output directory path
U16String outPath(u"..\\Data\\Output\\");
//Paths of source and output excel files
U16String damaskPath = dirPath + u"DamaskTheme.xlsx";
U16String sampleCopyThemeFromOneWorkbookToAnother = dirPath + u"sampleCopyThemeFromOneWorkbookToAnother.xlsx";
U16String outputCopyThemeFromOneWorkbookToAnother = outPath + u"outputCopyThemeFromOneWorkbookToAnother.xlsx";
//Read excel file that has Damask theme applied on it
Workbook damask(damaskPath);
//Read your sample excel file
Workbook wb(sampleCopyThemeFromOneWorkbookToAnother);
//Copy theme from source file
wb.CopyTheme(damask);
//Save the workbook in xlsx format
wb.Save(outputCopyThemeFromOneWorkbookToAnother, SaveFormat::Xlsx);
Aspose::Cells::Cleanup();