Description
Aspose get wrong json content result when save a xlsx as json format.
Env
- Windows 10 .NET 4.7
- Aspose.Cells for .NET 22.12
Q1
Json’s structure is not consistent when a xlsx file has only one sheet and the other xlsx file has two sheets.
- Only one sheet output (Array):
[{....},{....},{....}]
- Two or more sheets output (Object):
{"Sheet1":[{...},{...}], "Sheet2":[{...},{...}]}
- Both of them expected result should be (keep the json structure is consistent):
{"Sheet1":[{...},{...}]}
{"Sheet1":[{...},{...}], "Sheet2":[{...},{...}]}
Code:
for (var i = 1; i <= 2; i++)
{
var doc = new Aspose.Cells.Workbook(@"C:\Users\XCL\Desktop\test\" + i + ".xlsx");
var ops = new Aspose.Cells.JsonSaveOptions();
ops.ExportNestedStructure = true;
doc.Save(@"C:\Users\XCL\Desktop\test\" + i + ".json", ops);
}
Test Files:
test.zip (14.6 KB)
Q2
Json’s value is missing when a sheet is empty.
Code:
var doc = new Aspose.Cells.Workbook(@"C:\Users\XCL\Desktop\test\1.xlsx");
var ops = new Aspose.Cells.JsonSaveOptions();
ops.ExportNestedStructure = true;
doc.Save(@"C:\Users\XCL\Desktop\test\1.json", ops);
Received Json Result:
{
"Sheet1":[
{
"ID-1": 1
},
{
"ID-1": 2
},
{
"ID-1": 3
},
{
"ID-1": 4
},
{
"ID-1": 5
},
{
"ID-1": 6
},
{
"ID-1": 7
},
{
"ID-1": 8
},
{
"ID-1": 9
},
{
"ID-1": 10
}
],
"Sheet2":
}
Expected Result:
{
"Sheet1":[
{
"ID-1": 1
},
{
"ID-1": 2
},
{
"ID-1": 3
},
{
"ID-1": 4
},
{
"ID-1": 5
},
{
"ID-1": 6
},
{
"ID-1": 7
},
{
"ID-1": 8
},
{
"ID-1": 9
},
{
"ID-1": 10
}
],
"Sheet2":[] //It should be a empty array if a sheet is empty.
}
Test Files:
test.zip (7.7 KB)
Q3
JsonSaveOptions.SkipEmptyRows
is not working.
Code:
var doc = new Aspose.Cells.Workbook(@"C:\Users\XCL\Desktop\test\1.xlsx");
var ops = new Aspose.Cells.JsonSaveOptions();
ops.ExportNestedStructure = true;
ops.SkipEmptyRows = true;
doc.Save(@"C:\Users\XCL\Desktop\test\1.json", ops);
Received Result:
[
{
"ID-1": 1
},
{
"ID-1": 2
},
{
"ID-1": 3
},
null,
null,
{
"ID-1": 4
},
{
"ID-1": 5
},
{
"ID-1": 6
},
{
"ID-1": 7
},
{
"ID-1": 8
},
{
"ID-1": 9
},
{
"ID-1": 10
}
]
Expected Result:
[
{
"ID-1": 1
},
{
"ID-1": 2
},
{
"ID-1": 3
},
{
"ID-1": 4
},
{
"ID-1": 5
},
{
"ID-1": 6
},
{
"ID-1": 7
},
{
"ID-1": 8
},
{
"ID-1": 9
},
{
"ID-1": 10
}
]
Test Files:
test.zip (7.0 KB)