Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-cloud-kb/ff023244e3ace68f4ad6477f75beaf82 to your computer and use it in GitHub Desktop.
Save aspose-cloud-kb/ff023244e3ace68f4ad6477f75beaf82 to your computer and use it in GitHub Desktop.
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Request;
try
{
string clientID = "ID";
string clientSecret = "Secret";
string apiBaseUrl = "https://api.aspose.cloud";
CellsApi cellsApi = new CellsApi(clientID, clientSecret, apiBaseUrl);
string fileName = "Sample.xlsx";
// Upload file to cloud
UploadFileRequest uploadFileRequest = new UploadFileRequest
{
path = fileName,
storageName = null,
UploadFiles = new Dictionary<string, Stream>
{
{ fileName, File.OpenRead(fileName) }
}
};
cellsApi.UploadFile(uploadFileRequest);
PutWorksheetChartRequest request = new PutWorksheetChartRequest
{
name = fileName,
sheetName = "Sheet1",
chartType = "pie",
upperLeftRow = 5,
upperLeftColumn = 5,
lowerRightRow = 40,
lowerRightColumn = 15,
area = "A2:B27",
isVertical = true,
folder = ""
};
cellsApi.PutWorksheetChart(request);
var stream = cellsApi.DownloadFile(new DownloadFileRequest() { path = fileName });
string filePath = "output.xlsx";
using (FileStream fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write))
{
stream.CopyTo(fileStream);
}
Console.WriteLine("Chart Added Successfully");
}
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