XlsxPreserveSamplesCS

 
using System;
using System.Collections.Generic;
using System.Text;

using GemBox.Spreadsheet;

namespace Samples
{
    class XlsxPreserveSamplesCS
    {
        [STAThread]
        static void Main(string[] args)
        {
            // TODO: If using GemBox.Spreadsheet Professional, put your serial key below.
            // Otherwise, if you are using GemBox.Spreadsheet Free, comment out the 
            // following line (Free version doesn't have SetLicense method). 
            // SpreadsheetInfo.SetLicense("YOUR-SERIAL-KEY-HERE");
            ExcelFile excelFile = new ExcelFile();
            string inputFileName = @"..\..\PreserveSamplesIN.xlsm"; 
            string outputFileName = @"..\..\PreserveSamplesOUT.xlsm";

            excelFile.LoadXlsx(inputFileName, XlsxOptions.PreserveKeepOpen);

            // Preservation is fully functional only in xlsx.
            excelFile.SaveXlsx(outputFileName);

            TryToDisplayGeneratedFile(outputFileName);
        }


        static void TryToDisplayGeneratedFile(string fileName)
        {
            try
            {
                System.Diagnostics.Process.Start(fileName);
            }
            catch (Exception)
            {
                Console.WriteLine(fileName + " created in application folder.");
            }
        }
    }
}

 

Importing Data From XLSX Files With .NET Spreadsheet Component