I have sample json data and want to create a xls file using that.
"{\"Id\":\"123\",\"Name\":\"DEMO\",\"Address\":\"US\",\"Team\":\"JK\"}"
Want to create a excel file stream which I will upload on azure storage using below code -
CloudFile cloudFile = cloudFileDirectory.GetFileReference("filename.xls");
cloudFile.UploadFromStream(fileStream);
I'm able to create csv by below code -
var result = new StringBuilder();
for (int i = 0; i < table.Columns.Count; i++)
{
result.Append(table.Columns[i].ColumnName);
result.Append(i == table.Columns.Count - 1 ? "\n" : delimator);
}
foreach (DataRow row in table.Rows)
{
for (int i = 0; i < table.Columns.Count; i++)
{
result.Append(row[i].ToString());
result.Append(i == table.Columns.Count - 1 ? "\n" : delimator);
}
}
return result.ToString().TrimEnd(new char[] { '\r', '\n' });
If you already have a datatable, then you can convert a data table to a spreadsheet as easy as pie using EPPLus. The code could be as simple as this:
If you have some special handling, for date formats and such, it might be moderately more work, but not much.
From Nuget:
If you've ever worked with Excel Interop, you will love how much easier EPPlus is to work with.
to generate xls file from json files you should done those steps