将主题从一个工作簿复制到另一个
Contents
[
Hide
]
将主题从一个工作簿复制到另一个
以下示例代码显示了如何从一个工作簿复制主题进入另一个工作簿.该代码对于应用内置或自定义主题很有用。只需使用 Microsoft Excel 在模板文件中创建所需的主题(它可以是内置主题,也可以自定义),然后使用以下代码将其复制到源工作簿。
示例代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\TechnicalArticles\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Paths of source and output excel files | |
StringPtr damaskPath = dirPath->StringAppend(new String("DamaskTheme.xlsx")); | |
StringPtr sampleCopyThemeFromOneWorkbookToAnother = dirPath->StringAppend(new String("sampleCopyThemeFromOneWorkbookToAnother.xlsx")); | |
StringPtr outputCopyThemeFromOneWorkbookToAnother = outPath->StringAppend(new String("outputCopyThemeFromOneWorkbookToAnother.xlsx")); | |
//Read excel file that has Damask theme applied on it | |
intrusive_ptr<IWorkbook> damask = Factory::CreateIWorkbook(damaskPath); | |
//Read your sample excel file | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(sampleCopyThemeFromOneWorkbookToAnother); | |
//Copy theme from source file | |
wb->CopyTheme(damask); | |
//Save the workbook in xlsx format | |
wb->Save(outputCopyThemeFromOneWorkbookToAnother, SaveFormat_Xlsx); |