Description
Json content is wrong when convert a xlsx file to json file by Aspose.Cells.
Env
- Windows 10 .NET 4.7
- Aspose.Cells for .NET 22.12
Code
var doc = new Aspose.Cells.Workbook(@"C:\Users\XCL\Desktop\test\source.xlsx");
var ops = new Aspose.Cells.JsonSaveOptions();
ops.ExportNestedStructure = true; // if remove this line or fill a string like 'ID' into first cell, it's OK.
doc.Save(@"C:\Users\XCL\Desktop\test\target.json", ops);
Received Json Content
[
{
1
},
{
2
},
{
3
},
{
4
},
{
5
},
{
6
},
{
7
},
{
8
},
{
9
},
{
10
}
]
Expected Json Content
[
{
"1": 2
},
{
"1": 3
},
{
"1": 4
},
{
"1": 5
},
{
"1": 6
},
{
"1": 7
},
{
"1": 8
},
{
"1": 9
},
{
"1": 10
}
]
Test File
test.zip (6.0 KB)
@xucongli1989
The value of A1 is numberic, so we can not process it as header.
Please change the value of A1 as string value now.
We will check whether we can export your template file as your excepted too.
@xucongli1989
We will enhance the feature about JsonSaveOptions.HasHeaderRow.
If JsonSaveOptions.HasHeaderRow is set as true, we will force the first row as header.
We have log it with issue it CELLSNET-52498.
@xucongli1989
It will be supported in the next release 23.1.
When 23.1 is released , please try the following codes with 23.1
Workbook workbook = new Workbook(Constants.sourcePath +“CellsNet52498.xlsx”);
var ops = new Aspose.Cells.JsonSaveOptions();
ops.ExportNestedStructure = true; // if remove this line or fill a string like ‘ID’ into first cell, it’s OK.
ops.HasHeaderRow = true;
workbook.Save(Constants.destPath + “CellsNet52498.json”, ops);
The issues you have found earlier (filed as CELLSNET-52498) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi