Hi Aspose,
I have been looking into the JsonLayoutOptions() for Converting JSON to Excel but there are a couple of properties that don’t appear to do anything to the output.
I have reviewed the following documents:
JsonLayoutOptions | Aspose.Cells for .NET API Reference
Import Data into Worksheet|Documentation (aspose.com)
I have implemented the following code:
// Create a Worksheet and assign name
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Name = docMessage.JsonToExcelWorksheetName;
// Read JSON File or data
string jsonInput = File.ReadAllText(docMessage.FilePath);
// Set Styles
CellsFactory factory = new CellsFactory();
Aspose.Cells.Style style = factory.CreateStyle();
style.HorizontalAlignment = TextAlignmentType.Center;
style.Font.Color = System.Drawing.Color.BlueViolet;
style.Font.IsBold = true;
// Set JsonLayoutOptions
JsonLayoutOptions options = new JsonLayoutOptions();
// I can see a visible difference to the output
options.ArrayAsTable = true;
options.IgnoreArrayTitle = true;
options.TitleStyle = style;
// I can't see any difference to the outputted Excel spreadsheet
options.IgnoreObjectTitle = true;
options.ConvertNumericOrDate = true;
options.IgnoreNull = true;
options.DateFormat = "yyyy/MM/dd";
//Import JSON Data
JsonUtility.ImportData(jsonInput, worksheet.Cells, docMessage.JsonToExcelRow,
docMessage.JsonToExcelColumn, options);
// Save Excel file
workbook.Save(coreApiRDoc.FilePath);
Can you elaborate on what the effect is on the saved Excel document using the following properties, as they don’t seem to do anything?
// I can't see any difference to the outputted excel spreadsheet
options.IgnoreObjectTitle = false;
options.ConvertNumericOrDate = true;
options.IgnoreNull = true;
options.DateFormat = "yyyy/MM/dd";
To my mind, the DateFormat for example, should set the date format, but nothing changes to cells with a date in them.
Thanks in advance.