Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-cloud-kb/eae4cc0cfe85cc5ba36509a86cb0cd84 to your computer and use it in GitHub Desktop.
Save aspose-cloud-kb/eae4cc0cfe85cc5ba36509a86cb0cd84 to your computer and use it in GitHub Desktop.
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 XlsxToCsvConverter
{
public void XlsxToCsv()
{
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.xlsx";
string outputFileName = "XlsxtoCsv.csv";
CellsApi xlsxtoCsvApi = new CellsApi(clientID, clientSecret, apiBaseUrl);
var xlsxToCsvRequest = new PostConvertWorkbookToCSVRequest()
{
checkExcelRestriction = true,
File = new Dictionary<string, Stream>()
{
{
inputFileName, File.OpenRead(localPath + inputFileName)
}
},
};
var response = xlsxtoCsvApi.PostConvertWorkbookToCSV(xlsxToCsvRequest);
File.WriteAllBytes(localPath + outputFileName, Convert.FromBase64String(response.FileContent));
Console.WriteLine("XLSX to CSV 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