I've following code that maps given json array of objects to excel file. But it outputs the file with headers in lower case. I want the headers to be in Pascal Case. Can someone help or lead me to right direction? Either I should do it with json functions or aspose methods. I'm confused, as I couldn't find anything about header's cases for excel in documentation of Aspose. Thank you.
private async Task<string> JsonToExcel(string jsonString)
{
try
{
Workbook workbook = new();
Worksheet worksheet = workbook.Worksheets[0];
// Set JsonLayoutOptions
JsonLayoutOptions options = new();
options.ArrayAsTable = true;
// Import JSON Data
JsonUtility.ImportData(jsonString, worksheet.Cells, 0, 0, options);
// Save Excel file
Guid guid = Guid.NewGuid();
string filename = DateTimeOffset.Now.ToString("yyyy_MM_dd") + guid.ToString() + ".xlsx";
string path = _hostEnvironment.ContentRootPath + "Output\\";
worksheet.PageSetup.PrintGridlines = true;
worksheet.PageSetup.FitToPagesWide = 1;
workbook.Save(path + filename, SaveFormat.Xlsx);
return (path + filename);
}
catch (Exception)
{
throw;
}
}
I tried to set headers to camel case using reference of PageSetup of Worksheet as shown in the documentation but nothing related to pascal case :(
// Instantiating a Workbook object
Workbook excel = new Workbook();
// Obtaining the reference of the PageSetup of the worksheet
PageSetup pageSetup = excel.Worksheets[0].PageSetup;
// Setting worksheet name at the left section of the header
pageSetup.SetHeader(0, "&A");
