Last active
August 11, 2024 16:19
Convert Excel to HTML with NET REST API. https://kb.aspose.cloud/cells/net/convert-excel-to-html-with-net-rest-api/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment