2
I am making an application to export the result of a query sql for Excel. After the file created the time I will open it gives a corrupt file error.
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Execl files (*.xls)|*.xls";
sfd.FileName = "teste";
if (sfd.ShowDialog() == DialogResult.OK)
{
Stream s = File.Open(sfd.FileName, FileMode.CreateNew);
xlApp.DisplayAlerts = false;
xlWorkBook.SaveAs(s, Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel12,
Missing.Value, Missing.Value, false, false,
Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlUserResolution,
true, Missing.Value, Missing.Value, Missing.Value);
xlWorkBook.Close(true, misValue, misValue);
}
Would it be possible for you to make one of these corrupted files available?
– André Ribeiro
The files are with 0b has no way to make up the file to send you, you have any idea how I can do it?
– Thiago Beltrame
Then add in your question the code snippet where you add the content to the Workbook.
– André Ribeiro