Copiar Tema de un Libro a Otro

Copiar Tema de un Libro a Otro

El siguiente código de muestra muestra cómo copiar un tema de un libro en otro libro. El código es útil para aplicar temas integrados o personalizados. Simplemente crea tu tema deseado (puede ser un tema integrado o personalizado) en tu archivo de plantilla utilizando Microsoft Excel y luego cópialo en tu libro fuente usando el siguiente código.

Código de muestra

//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();