I'm using ExcelPackage throughout my wpf application for generating csvs and xlsxs, whenever I open a xlsx that has been generated by epplus in excel it opens without an error, but when I open a generated csv in excel it shows me
"The file format and extension bonus of "filename.csv" don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway?"
Pressing yes opens the file with no problems, but this error is showing to users and is quite annoying so I'd like to fix it..
The code that is generating the csv is nothing fancy.
using (ExcelPackage p = new ExcelPackage(new FileInfo(path + filename)))
{
//Create a sheet
p.Workbook.Worksheets.Add("User Ids");
ExcelWorksheet ws = p.Workbook.Worksheets[1];
for (int i = 0; i < lstCsvUsers.Items.Count; i++)
{
ws.Cells[i + 1, 1].Value = lstCsvUsers.Items[i].ToString();
}
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
p.Save();
}
But is it missing something to prevent this error from showing to the user when they open the generated file in excel/ other software?