The Aspose.Cells Cloud .NET SDK underwent a major architectural change with version 26.11, introducing a new model that simplifies development and improves consistency across SDKs. This guide walks you through the key differences between the old and new models and shows you how to migrate your existing code.
Key Differences: Old vs. New Model
The new model (v26.11+) introduces several conceptual changes:
| Aspect | Old Model | New Model |
|---|---|---|
| Client Class | CellsApi |
AsposeCellsCloudClient |
| API Version | Passed in constructor (v4.0) | Hardcoded to v4.0 in each request |
| Input/Output | File paths as strings | DataSource / DataSink interfaces |
| Convenience Methods | Scattered across API classes | Grouped into static facades: Conversion, DataProcessor, WorksheetEditor, Cleansing, TextSearcher |
| Error Handling | Manual response parsing | Automatic 2xx validation; throws ApiException |
Old Model Structure
// Old model required manual request construction
CellsApi api = new CellsApi(clientId, clientSecret, baseUrl);
ConvertSpreadsheetRequest request = new ConvertSpreadsheetRequest();
request.Spreadsheet = "Book1.xlsx";
request.format = "pdf";
api.ConvertSpreadsheet(request, "output.pdf");
New Model Structure
// New model uses static facades for simpler usage
AsposeCellsCloudClient client = new AsposeCellsCloudClient(clientId, clientSecret, baseUrl);
Conversion.Convert(client, "Book1.xlsx", "output.pdf", Formats.Pdf);
Migration Examples
Example 1: Converting Excel to PDF
Old Model (v26.10 and earlier)
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Request;
CellsApi cellsApi = new CellsApi(
Environment.GetEnvironmentVariable("ProductClientId"),
Environment.GetEnvironmentVariable("ProductClientSecret")
);
// Build request with property initialization
ConvertSpreadsheetRequest request = new ConvertSpreadsheetRequest
{
Spreadsheet = "EmployeeSalesSummary.xlsx",
format = "pdf"
};
// Execute conversion
cellsApi.ConvertSpreadsheet(request, "EmployeeSalesSummary.pdf");
New Model (v26.11+)
using Aspose.Cells.Cloud;
using Aspose.Cells.Cloud.SDK.Converter;
AsposeCellsCloudClient client = new AsposeCellsCloudClient(
Environment.GetEnvironmentVariable("ProductClientId"),
Environment.GetEnvironmentVariable("ProductClientSecret"),
"https://api.aspose.cloud"
);
// Single-line conversion with static facade
Conversion.Convert(client, "EmployeeSalesSummary.xlsx", "EmployeeSalesSummary.pdf", Formats.Pdf);
Example 2: Converting Excel to Word (DOCX)
Old Model (v26.10 and earlier)
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Request;
CellsApi cellsApi = new CellsApi(
Environment.GetEnvironmentVariable("ProductClientId"),
Environment.GetEnvironmentVariable("ProductClientSecret")
);
ConvertSpreadsheetRequest request = new ConvertSpreadsheetRequest
{
Spreadsheet = "input.xlsx",
format = "docx"
};
cellsApi.ConvertSpreadsheet(request, "output.docx");
New Model
using Aspose.Cells.Cloud;
using Aspose.Cells.Cloud.SDK.Converter;
AsposeCellsCloudClient client = new AsposeCellsCloudClient(
Environment.GetEnvironmentVariable("ProductClientId"),
Environment.GetEnvironmentVariable("ProductClientSecret"),
"https://api.aspose.cloud"
);
// Using the convenience method
Conversion.ConvertToDocx(client, "input.xlsx", "output.docx");
// Or specify format explicitly
Conversion.Convert(client, "input.xlsx", "output.docx", Formats.Docx);
Example 3: Splitting a Spreadsheet
Old Model (v26.10 and earlier)
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Request;
CellsApi cellsApi = new CellsApi(
Environment.GetEnvironmentVariable("ProductClientId"),
Environment.GetEnvironmentVariable("ProductClientSecret")
);
// For local file split
SplitSpreadsheetRequest request = new SplitSpreadsheetRequest
{
Spreadsheet = "Book1.xlsx",
outFormat = "PDF"
};
cellsApi.SplitSpreadsheet(request, "output.zip");
// For remote file split
SplitRemoteSpreadsheetRequest remoteRequest = new SplitRemoteSpreadsheetRequest
{
name = "Book1.xlsx",
folder = "TestData/In",
outFormat = "PDF",
outPath = "TestData/Out"
};
cellsApi.SplitRemoteSpreadsheet(remoteRequest, null);
New Model
using Aspose.Cells.Cloud.SDK.DataProcessing;
using Aspose.Cells.Cloud;
// Split local file - returns zip archive with split files
DataProcessor.SplitSpreadsheet(client, "Book1.xlsx", "output.zip");
// For cloud files:
DataProcessor.SplitRemoteSpreadsheet(client, WorkbookRef.Of("Book1.xlsx"), "output/");
Example 4: Merging Spreadsheets
Old Model (v26.10 and earlier)
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Request;
CellsApi cellsApi = new CellsApi(
Environment.GetEnvironmentVariable("ProductClientId"),
Environment.GetEnvironmentVariable("ProductClientSecret")
);
// Merge local files using dictionary
MergeSpreadsheetsRequest request = new MergeSpreadsheetsRequest();
Dictionary<string, Stream> mapFiles = new Dictionary<string, Stream>();
mapFiles.Add("Book1.xlsx", File.OpenRead(@"c:\testdata\Book1.xlsx"));
mapFiles.Add("Book2.xlsx", File.OpenRead(@"c:\testdata\Book2.xlsx"));
request.Spreadsheet = mapFiles;
request.outFormat = "pdf";
cellsApi.MergeSpreadsheets(request, "MergedResultFile.pdf");
// Merge remote file into cloud file
MergeRemoteSpreadsheetRequest remoteRequest = new MergeRemoteSpreadsheetRequest();
remoteRequest.name = "Book1.xlsx";
remoteRequest.folder = "RemoteFolder1";
remoteRequest.mergedSpreadsheet = "RemoteFolder2/Book2.xlsx";
remoteRequest.outFormat = "pdf";
cellsApi.MergeRemoteSpreadsheet(remoteRequest, "MergedResultOutPutToLocalFile.pdf");
New Model
using Aspose.Cells.Cloud.SDK.DataProcessing;
using Aspose.Cells.Cloud;
// Merge local files
DataProcessor.MergeSpreadsheet(client, "file1.xlsx", "merged.xlsx");
// Merge remote file into local
DataProcessor.MergeRemoteSpreadsheet(
client,
WorkbookRef.Of("remote-file.xlsx"),
"local-template.xlsx",
"merged-output.xlsx"
);
Example 5: Adding a Worksheet
Old Model (v26.10 and earlier)
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Request;
CellsApi cellsApi = new CellsApi(
Environment.GetEnvironmentVariable("ProductClientId"),
Environment.GetEnvironmentVariable("ProductClientSecret")
);
// For cloud files, upload first then add worksheet
// (Old model required separate upload step)
New Model
using Aspose.Cells.Cloud.SDK.Editor;
// Add a worksheet to local file
WorksheetEditor.AddWorksheet(client, "Book1.xlsx", "updated.xlsx", "NewSheet");
Example 6: Replacing Text in a Spreadsheet
Old Model (v26.10 and earlier)
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Request;
CellsApi cellsApi = new CellsApi(
Environment.GetEnvironmentVariable("ProductClientId"),
Environment.GetEnvironmentVariable("ProductClientSecret")
);
// Replace text in local file
ReplaceSpreadsheetContentRequest request = new ReplaceSpreadsheetContentRequest(
"Aspose.Cells Product Readme.xlsx",
"Aspose.Cells",
"Aspose.Cells Cloud"
);
cellsApi.ReplaceSpreadsheetContent(request, "Aspose.Cells Cloud Product Readme.xlsx");
New Model
using Aspose.Cells.Cloud.SDK.Searcher;
using Aspose.Cells.Cloud;
// Replace text in local file - returns modified workbook
TextSearcher.Replace(client, "BookText.xlsx", "updated.xlsx", "Bike", "****");
// Or for cloud files, replace in place:
TextSearcher.ReplaceWorkbook(client, WorkbookRef.Of("BookText.xlsx"), "Bike", "****");
Example 7: Data Cleansing (Trimming)
Old Model (v26.10 and earlier)
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Request;
using Aspose.Cells.Cloud.SDK.Model;
CellsApi cellsApi = new CellsApi(
Environment.GetEnvironmentVariable("ProductClientId"),
Environment.GetEnvironmentVariable("ProductClientSecret")
);
// Build trim content request with complex nested objects
PostTrimContentRequest request = new PostTrimContentRequest
{
trimContentOptions = new TrimContentOptions
{
DataSource = new DataSource { DataSourceType = "RequestFiles" },
FileInfo = new FileInfo { Filename = "BookText.xlsx", FileContent = Convert.ToBase64String(File.ReadAllBytes("BookText.xlsx")) },
RemoveAllLineBreaks = true,
RemoveExtraLineBreaks = true,
TrimSpaceBetweenWordTo1 = true,
ScopeOptions = new ScopeOptions
{
Scope = "SelectionOlny",
ScopeItems = new List<ScopeItem> { new ScopeItem { Worksheet = "Sales", Ranges = new List<string> { "B1:B3"} } }
}
}
};
// Post trim content Web API request
var response = cellsApi.PostTrimContent(request);
// Save result: convert base64 string to file
File.WriteAllBytes("BookText_TrimContent.xlsx", Convert.FromBase64String(response.FileContent));
New Model
using Aspose.Cells.Cloud.SDK.Cleansing;
// Remove blank rows from local file
Cleansing.RemoveBlankRows(client, "Book1.xlsx", "cleaned.xlsx");
// Remove blank columns
Cleansing.RemoveBlankColumns(client, "Book1.xlsx", "cleaned.xlsx");
// Remove duplicates
Cleansing.RemoveDuplicates(client, "Book1.xlsx", "cleaned.xlsx");
New Model Advantages
1. Consistent Interface Across SDKs
The new model follows a consistent pattern across all Aspose.Cells Cloud SDKs (.NET, Java, Python, Node.js, etc.), making it easier to share knowledge and code patterns.
2. Type-Safe Input/Output
// Old model: strings everywhere
api.ConvertSpreadsheet("file.xlsx", "pdf"); // Ambiguous what these are
// New model: explicit types
Conversion.Convert(client,
new FilePathSource("file.xlsx"), // Clearly input
new FilePathSink("output.pdf"), // Clearly output
Formats.Pdf
);
3. Simplified Error Handling
// Old model: Manual response checking
try
{
var response = api.ConvertSpreadsheet(request);
// Process response
}
catch (ApiException ex)
{
// Handle error
}
// New model: Exceptions for errors
try
{
Conversion.Convert(client, "input.xlsx", "output.pdf", Formats.Pdf);
}
catch (ApiException ex)
{
Console.WriteLine($"Error {ex.StatusCode}: {ex.Message}");
}
4. Async/Await Support
// New model provides async methods out of the box
await Conversion.ConvertToPdfAsync(client, src, sink, options);
await DataProcessor.MergeSpreadsheetAsync(client, src, sink, options);
await WorksheetEditor.AddWorksheetAsync(client, src, sink, sheetName, options);
5. Method Chaining for Options
Conversion.Convert(client,
"input.xlsx",
"output.pdf",
Formats.Pdf,
FacadeOptions.AutoColumnsFit(true),
FacadeOptions.AutoRowsFit(true),
FacadeOptions.FontsLocation("/custom/fonts")
);
Summary Checklist
Before you migrate:
- Update your NuGet package to
Aspose.Cells-Cloudversion 26.11 or later - Replace
CellsApiwithAsposeCellsCloudClient - Replace string paths with
DataSource/DataSinkinstances (FilePathSource,FilePathSink, etc.) - Use static facade methods:
Conversion,DataProcessor,WorksheetEditor,Cleansing,TextSearcher - Replace manual request building with direct method calls
- Update error handling to use
ApiException - Consider converting synchronous calls to async/await patterns