Hi Support,
Hi Andrea,
Thanks for using Aspose.Cells.
When you save to stream, then specify the SaveFormat.Xlsm. It will then save the workbook in xlsm format inside the stream.
The following code works fine and generates two xlsm files from the source xlsm file and macros are preserved. I have attached the output xlsm files for your reference.
C#
string filePath = @“F:\Shak-Data-RW\Downloads\Test_Excel\Orig.xlsm”;
Workbook WBOrig = new Workbook(filePath);
using (MemoryStream stream1 = new MemoryStream())
{
WBOrig.Save(stream1, SaveFormat.Xlsm);
Workbook Destination1 = new Workbook(stream1);
Destination1.Save(filePath + @“Destination_SaveFormat1.xlsm”);
}
using (MemoryStream stream2 = new MemoryStream())
{
WBOrig.Save(stream2, SaveFormat.Xlsm);
Workbook Destination2 = new Workbook(stream2);
Destination2.Save(filePath + @“Destination_SaveFormat2.xlsm”);
}