TOTAL NEWBIE here and I am using http requests in a no-code platform to call Aspose.cells API.
I’ve only been able to find how to update the value of a single cell at a time.
I cannot seem to find how to update multiple cells in one API call.
I see that I can update cells or a range with the SAME value, but I cannot figure out how to update a sheet, for example, with multiple values for multiple cells in the same JSON request of an API call.
Any help would be greatly appreciated.
Sincerely
Is this even possible, or nah?
So, this API, designed to programmatically export xlsx files via JSON input, does not support actually inputting values throughout the sheet, but only one cell at a time?
@aiplusautomation ,
We apologize for the delay in getting back to you.
The Cells Cloud API supports the bulk import of data. For example, the ImportData API.
Please check ImportBatchDataOption and PostImportData specification.
And please also refer to the Net test case:
var url = BuildUrl(string.Format("{0}/importdata?folder={1}", TestImportDataXlsx, TempFolderPath));
dynamic option = new ExpandoObject();
option.DestinationWorksheet = Sheet2;
option.IsInsert = false;
option.BatchData = new List<dynamic>();
const int row = 0;
const int column = 0;
for (var i = 0; i < 10; i++)
{
for (var j = 0; j < 10; j++)
{
dynamic cellValue = new ExpandoObject();
cellValue.rowIndex = row + i;
cellValue.columnIndex = column + j;
cellValue.type = i % 3 == 0 ? "int" : "string";
cellValue.value = i + j;
cellValue.style = new ExpandoObject();
cellValue.style.BackgroundColor = new ExpandoObject();
cellValue.style.ForegroundColor = new ExpandoObject();
cellValue.style.Font = new ExpandoObject();
cellValue.style.BackgroundColor.R = 65;
cellValue.style.BackgroundColor.G = 105;
cellValue.style.BackgroundColor.B = 225;
cellValue.style.ForegroundColor.R = 32;
cellValue.style.ForegroundColor.G = 64;
cellValue.style.ForegroundColor.B = 128;
cellValue.style.Font.IsBold = false;
cellValue.style.Font.IsItalic = true;
cellValue.style.Font.IsStrikeout = true;
cellValue.style.Font.Size = 24;
cellValue.style.Font.Name = "Arial";
cellValue.style.RotationAngle = 70;
option.BatchData.Add(cellValue);
}
}
string bodyParam = JsonConvert.SerializeObject(option);
Dictionary<string, string> headParams = null;
Dictionary<string, object> formParams = null;
var response = ApiInvoker.InvokeApiAsync<dynamic>(url, "POST", bodyParam, headParams, formParams).Result;
Assert.AreEqual(HttpStatusCode.OK.ToString(), (string)response.Status.Value);
option.importDataType = "BatchData";
bodyParam = JsonConvert.SerializeObject(option);
response = ApiInvoker.InvokeApiAsync<dynamic>(url, "POST", bodyParam, headParams, formParams).Result;
Assert.AreEqual(HttpStatusCode.OK.ToString(), (string)response.Status.Value);
1 Like