Copia il tema da una cartella di lavoro a un'altra

Copia il tema da una cartella di lavoro a un’altra

Il codice di esempio seguente mostra comecopiare il tema da una cartella di lavoro inun’altra cartella di lavoro. Il codice è utile per applicare temi integrati o personalizzati. Basta creare il tema desiderato (potrebbe essere un tema integrato o personalizzarlo) nel file modello utilizzando Microsoft Excel e quindi copiarlo nella cartella di lavoro di origine utilizzando il seguente codice.

Codice d’esempio

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