This project has moved and is read-only. For the latest updates, please go here.

Save As XLSM Memory Stream

Dec 22, 2014 at 9:32 PM
I need to save as XLSM. It's opens the xlsm file and modifies but saves it as xlsx. I need to know how to save it as XLSM. Thanks
            const string newPath = "ExcelFiles/70005070.xlsm";
            var fullPath = string.Format("{0}{1}", appPath, newPath);

            var existingFile = new FileInfo(fullPath);
            using (var package = new ExcelPackage(existingFile,true))
            {
                var ws = package.Workbook.Worksheets[1];
                ws.Cells["D2"].Value = contractinfo.MyVendorInfo.VendorName;
                ws.Cells["D4"].Value = contractinfo.ContractId;
                ws.Cells["K2"].Value = contractinfo.PrimeProjectId;
                ws.Cells["K4"].Value = contractinfo.FederalAidProjectNumber;
                ws.Cells["U4"].Value = contractinfo.Description;

                ws.Protection.SetPassword("dogwood");

                using (var ms = new MemoryStream())
                {
                    package.SaveAs(ms);

                    return ms;
                }