Add ExportNestedStructure option when converting from xlsx to json with Cells Cloud

I’m developing an ASPNET mvc application. I’ve been trying out both the local and the cloud solutions offered by ASPOSE. When using the local version with a NuGet I’m able to convert an excel file to a json even when the excel has nested structures within it, because I can add options such as:

options.HasHeaderRow = true;
options.SortNames = false;
options.ExportNestedStructure = true;

This is pretty convenient because it allows me to convert excel files with nested structures to json and make those jsons contain the correct names of the nested columns.
When using the local version and adding the options.ExportNestedStructure = true, the nested structures in the json appear with the correct names as follows:

JSON
{
“TEACHER NAME”: “JOHN JONES”,
“EMAIL”: “jon@gmail.com”,
“SUBJECTS”: [
{
“SUBJECTNAME”: “ENGLISH”,
“GRADE”: “1ST”,
“HOURS”: “1”
},
{
“SUBJECTNAME”: “FRENCH”,
“GRADE”: “2ND”,
“HOURS”: “2”
},
]
}

I cant find a way to add the option ExportNestedStructure when using the cloud version. So the resulting json looks as follows:

JSON
{
“SUBJECTS”: “SUBJECTNAME”,
“Column4”: “GRADE”,
“Column5”: “HOURS”
},
{
“TEACHER NAME”: “JOHN JONES”,
“EMAIL”: “jon@gmail.com”,
“SUBJECTS”: “ENGLISH”,
“Column4”: “1ST”,
“Column5”: “1”
},
{
“SUBJECTS”: “MATH”,
“Column4”: “2nd”,
“Column5”: “2”
}
}

Not only is it doing a bad job structuring the json, the nested structures are not properly mapped. Is there a way to add the options to the request the same way when using the local version? or is it not possible with the cloud version.

Example of local call:
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(streamExcel);

// Initialize JsonSaveOptions class object
Aspose.Cells.JsonSaveOptions options = new Aspose.Cells.JsonSaveOptions();
options.HasHeaderRow = true;
options.SortNames = false;
options.ExportNestedStructure = true;

Example of cloud call:
filename = filename+“.json”;
var request2 = new PutConvertWorkbookRequest(file: mapFiles, format: “JSON”, outPath: filename);
var result = cellsInstance.PutConvertWorkbook(request2);

@luis.coronado.ftsoftware ,
We have found the cause and will give you a solution soon.

@luis.coronado.ftsoftware ,

We have fixed the Extended Query Parameters feature and updated the AsposeCells-Cloud version to 24.6.1 on Nuget. Please update to the latest version and refer to the following code for testing. If it still doesn’t meet your requirements, please provide the test file and we will solve it for you as soon as possible.

CellsApi cellsApi = new CellsApi("your client id ", "your client secrent");
PutConvertWorkbookRequest putConvertWorkbookRequest = new PutConvertWorkbookRequest();
putConvertWorkbookRequest.File = new Dictionary<string, Stream> { { "Book1.xlsx", File.OpenRead(@"D:\cells.cloud.family\cells.cloud-toolset\TestData\Book1.xlsx") } };
putConvertWorkbookRequest.format = "json";
putConvertWorkbookRequest.extendQueryParameterMap = new Dictionary<string, string>();
putConvertWorkbookRequest.extendQueryParameterMap.Add("HasHeaderRow", "true");
putConvertWorkbookRequest.extendQueryParameterMap.Add("SortNames", "false");
putConvertWorkbookRequest.extendQueryParameterMap.Add("ExportNestedStructure", "true");

using (var result = cellsApi.PutConvertWorkbook(putConvertWorkbookRequest))
{
    using (var writer = File.OpenWrite(@"C:\output\result.json"))
    {
        result.CopyTo(writer);
        writer. Flush();
        writer. Close(); 
        writer. Dispose();
    }
}

Hi @wangtao , I appreciate the fast response. We are still having some trouble. The added functionality does indeed work. But when trying to download the parsed json which is saved in a storage for future usage it sometimes works and it sometimes does not. We think it has something to do with how long it takes the API to respond back with the donwloadFile() method. We don’t know if its an error from our side or if its an error from your side, but when checking the logs on your website we see that there are no failing DownloadFile requests. We are coding in ASPNET MVC, and it sometimes works and it sometimes doesn’t, giving us the following error when it fails:

C#
System.AggregateException
HResult=0x80131500
Message=One or more errors occurred. (An error occurred while sending the request.)
Source=System.Private.CoreLib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.get_Result()
at Aspose.Cells.Cloud.SDK.Api.CellsApi.DownloadFile(DownloadFileRequest request)
at esign.Controllers.TemplateController.CrearMergeBatchCloud(IFormFile archivoExcel, String TemplateId) in D:\Developer\VisualStudio\Esign_Demo_32.0\Controllers\TemplateController.cs:line 210
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<g__Logged|12_1>d.MoveNext()
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
WebException: An error occurred while sending the request.
Inner Exception 2:
HttpRequestException: An error occurred while sending the request.
Inner Exception 3:
HttpIOException: The response ended prematurely.

@luis.coronado.ftsoftware ,
Thank you for your reply, this is a tricky question, we will check this issue as soon as possible and give you an effective solution.

@luis.coronado.ftsoftware ,
We ran several mock tests and didn’t come across the issues you mentioned. Can you give me some information about the account you called the API (e.g. clientId) and the time frame of the problem, we’ll continue looking in the system logs.

Hello @wangtao, once again the errors that I mentioned last time occurred, but this time I did take some screenshots of the process… I am attaching a pdf file with the screens and a brief description

ASpPose Case Error.pdf (2.9 MB)

@luis.coronado.ftsoftware ,
Thank you for your provided information. We will check it ASAP.