Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active August 26, 2020 15:59
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/55bb6393020059ce71f40ae8666e529b to your computer and use it in GitHub Desktop.
Save aspose-cloud/55bb6393020059ce71f40ae8666e529b to your computer and use it in GitHub Desktop.
Aspose.Cells-Cloud-NET
This Gist repository contains code snippet related to Aspose.Cells.Cloud SDK for NET
string MyAppKey = "xxxxxxxx"; // Get AppKey from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxxx"; // Get AppSID from https://dashboard.aspose.cloud/
try
{
Aspose.Cells.Cloud.SDK.Api.CellsApi cellsApi = new Aspose.Cells.Cloud.SDK.Api.CellsApi(MyAppSid, MyAppKey);
String fileName = "Family Budget1.xlsx";
string sheetName = "Sheet1";
Aspose.Cells.Cloud.SDK.Model.CreatePivotTableRequest createPivotTableRequest =
new Aspose.Cells.Cloud.SDK.Model.CreatePivotTableRequest();
createPivotTableRequest.Name = "NewPivot";
createPivotTableRequest.SourceData = "'Current Month'!$B$21:$C$24";
createPivotTableRequest.DestCellName = "G22";
createPivotTableRequest.UseSameSource = true;
createPivotTableRequest.PivotFieldColumns = new System.Collections.Generic.List<int?> { 1 };
createPivotTableRequest.PivotFieldRows = new System.Collections.Generic.List<int?> { 1 };
createPivotTableRequest.PivotFieldData = new System.Collections.Generic.List<int?> { 1 };
Aspose.Cells.Cloud.SDK.Model.PivotTableResponse pivotTableResponse =
cellsApi.CellsPivotTablesPutWorksheetPivotTable(fileName, sheetName, createPivotTableRequest);
if (pivotTableResponse != null && pivotTableResponse.Status.Equals("OK"))
{
Console.WriteLine("Add a Pivot Table in a Worksheet, Done!");
Console.ReadKey();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
string MyAppKey = "xxxxxxxx"; // Get AppKey from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxxx"; // Get AppSID from https://dashboard.aspose.cloud/
// Complete examples can be found over https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet
// create an instance of Cells Cloud API
Aspose.Cells.Cloud.SDK.Api.CellsApi cellsApi = new Aspose.Cells.Cloud.SDK.Api.CellsApi(MyAppSid, MyAppKey);
string fileName = "NewBook2056160256i53.xlsx";
String sheetName = "Sheet1";
String cellName = "A3";
Aspose.Cells.Cloud.SDK.Model.Style style = new Aspose.Cells.Cloud.SDK.Model.Style();
Aspose.Cells.Cloud.SDK.Model.Font font = new Aspose.Cells.Cloud.SDK.Model.Font();
font.IsBold = true;
font.Color = new Aspose.Cells.Cloud.SDK.Model.Color() { A = 10, R = 120, G = 200, B = 230 };
font.Size = 16;
Aspose.Cells.Cloud.SDK.Model.ThemeColor themeColor = new Aspose.Cells.Cloud.SDK.Model.ThemeColor();
themeColor.ColorType = "Text2";
themeColor.Tint = 2;
style.BackgroundThemeColor = themeColor;
style.Font = font;
try
{
// Invoke Aspose.Cells Cloud SDK API to change cell style
Aspose.Cells.Cloud.SDK.Model.StyleResponse apiResponse = cellsApi.CellsPostUpdateWorksheetCellStyle(fileName, sheetName, cellName, style);
if (apiResponse != null && apiResponse.Status.Equals("OK"))
{
Console.WriteLine("Change Cell Style in Excel Worksheet, Done!");
Console.ReadKey();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
string MyAppKey = "xxxxxxxx"; // Get AppKey from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxxx"; // Get AppSID from https://dashboard.aspose.cloud/
// Complete examples can be found over https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet
// create an instance of Cells Cloud API
CellsApi instance = new CellsApi(MyAppSid, MyAppKey);
// specify the name of resultant file
string name = "NewBook" + DateTime.Now.ToString("yymmddhhmiss") + ".xlsx";
// save the Excel file to Cloud storage
instance.CellsWorkbookPutWorkbookCreate(name);
// add worksheet to second location
instance.CellsWorksheetsPutAddNewWorksheet(name, "Sheet2", 2);
string MyAppKey = "xxxxxxxx"; // Get AppKey from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxxx"; // Get AppSID from https://dashboard.aspose.cloud/
// Complete examples can be found over https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet
// create an instance of Cells Cloud API
CellsApi instance = new CellsApi(MyAppSid, MyAppKey);
string name = "NewBook2056160256i53.xlsx";
string sheetName = "Sheet1";
int? firstRow = 0;
int? firstColumn = 0;
int? rowCount = 3;
int? columnCount = 2;
var response = instance.CellsRangesGetWorksheetCellsRangeValue(name, sheetName, null, firstRow, firstColumn, rowCount, columnCount);
NUnit.Framework.Assert.AreEqual(response.Code, 200);
var rangeName = "A1:B3";
response = instance.CellsRangesGetWorksheetCellsRangeValue(name, sheetName, rangeName, null, null, null, null);
NUnit.Framework.Assert.AreEqual(response.Code, 200);
rangeName = "MyRange";
response = instance.CellsRangesGetWorksheetCellsRangeValue(name, sheetName, rangeName, null, null, null, null);
NUnit.Framework.Assert.AreEqual(response.Code, 200);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment