从一个工作簿复制主题到另一个工作簿

从一个工作簿复制主题到另一个工作簿

以下示例代码显示了如何从一个工作簿复制主题到另一个工作簿。该代码可用于应用内置或自定义主题。只需在模板文件中使用Microsoft Excel创建所需的主题(可以是内置主题或自定义主题),然后使用以下代码将其复制到源工作簿。

示例代码

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