using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Request;
using System;
using System.Collections.Generic;
using System.IO;

namespace Kb_Aspose.KB
{
    public class XlsToHtmlConverter
    {
        public void XlsToHtml()
        {
            try
            {
                string clientID = "Id";
                string clientSecret = "Secret";
                string apiBaseUrl = "https://api.aspose.cloud";

                // Source and output file names
                string localPath = "C:/ExcelFiles/";
                string inputFileName = "Source.xls";
                string outputFileName = "XlstoHtml.html";

                CellsApi xlstoHtmlApi = new CellsApi(clientID, clientSecret, apiBaseUrl);

                var xlsToHtmlRequest = new PostConvertWorkbookToHtmlRequest
                {
                    checkExcelRestriction = true,
                    File = new Dictionary<string, Stream>()
                    {
                        {
                            inputFileName, File.OpenRead(localPath + inputFileName)
                        }
                    },
                };

                var response = xlstoHtmlApi.PostConvertWorkbookToHtml(xlsToHtmlRequest);

                File.WriteAllBytes(localPath + outputFileName, Convert.FromBase64String(response.FileContent));

                Console.WriteLine("XLS to HTML conversion completed");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}