Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active October 11, 2021 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/caf24cdbbfa6882e3524fd88ab327ba2 to your computer and use it in GitHub Desktop.
Save aspose-cloud/caf24cdbbfa6882e3524fd88ab327ba2 to your computer and use it in GitHub Desktop.
This gist contains code snippets related to conversion of XLSB files to JPEG format using Aspose.Cells Cloud SDK for .NET
This gist contains code snippets related to conversion of XLSB files to JPEG format using Aspose.Cells Cloud SDK for .NET
// For complete examples and data files, please go to
https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet/
// Get client credentials from https://dashboard.aspose.cloud/
string clientSecret = "d757548a9f2558c39c2feebdf85b4c44";
string clientID = "4db2f826-bf9c-42e7-8b2a-8cbca2d15553";
// create CellsApi instance while passing ClientID and ClientSecret
CellsApi instance = new CellsApi(clientID, clientSecret);
// name of input Excel file
string name = "TestCase.xlsb";
// name of resultant file
string resultantFile = "converted.jpeg";
// format of resultant file
string format = "JPEG";
// vertical and horizontal resolution for image
int? verticalResolution = 800;
int? horizontalResolution = 600;
// name of worksheet in workbook
string sheetName = "Sheet2";
try
{
// load XLSB file from local drive
using (var file = System.IO.File.OpenRead(@"C:\Users\Downloads\" + name))
{
// perform conversion and save output to Stream isntance
var response = instance.CellsWorksheetsGetWorksheet(name, sheetName, format, verticalResolution, horizontalResolution, null, null, null);
if (response != null && response.Equals("OK"))
{
// display confirmation message in console
Console.WriteLine("Successfully converted XLSB to JPEG !");
Console.ReadKey();
}
// call method to save the output on system drive
saveToDisk(response, @"C:\Users\shahbnay\Downloads\" + resultantFile);
}
}catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
// custom method to save stream over system
static void saveToDisk(Stream responseStream, String resultantFile)
{
var fileStream = File.Create(resultantFile);
responseStream.Seek(0, SeekOrigin.Begin);
responseStream.CopyTo(fileStream);
fileStream.Close();
}
@aspose-cloud
Copy link
Author

The Gist is marked as Public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment