I’m generating a CSV file from the following code
public ActionResult Index()
{
var csv = "मानक हिन्दी;some other value";
var data = Encoding.UTF8.GetBytes(csv);
data = Encoding.UTF8.GetPreamble().Concat(data).ToArray();
var cd = new ContentDisposition
{
Inline = false,
FileName = "newExcelSheet.csv"
};
Response.AddHeader("Content-Disposition", cd.ToString());
return File(data, "text/csv");
}
Now I wish to insert Image in the top row of the excel, Please assist me in the following problem
Thanks 🙂
CSV is not a format capable of including binary data such as images. The only thing you can include in a CSV file is text.
If you need to add an image to an excel document you would have to use a proper excel file (i.e. a
.xlsor.xlsxfile). There are various APIs that you can use to write to such files, including the Excel Object Model exposed through COM when you have Office installed.See this question for details on how to insert images through COM.