Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i saved all the entries in database.

then i export the data base in to excel for that i written a code.

when i click the button data base records are exported into excel.

A filename'csharp.netinformation.xls' already exists in this location.Do you want to replace it.

Yes NO Cancel.

i don't want this pop up message.
i want the message as;

Excel Report created.

Ok.
when user press ok open the excel file.

my code as follows;

C#
xlWorkBook.SaveAs("csharp.net-informations.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

xlApp.Visible = true;
releaseObject(xlApp);
releaseObject(xlWorkBook);
releaseObject(xlWorkSheet);


from my code how can i do. what changes required to get a pop up message.
when open a excel file by the user.

from my code please correct it.
Posted
Updated 22-Jan-13 1:09am
v2

You should add a quick check whether the file exists, and if it does remove it before trying to save the new document.
I'm not entirely sure if this will remove the save as dialog, but it's worth a try.
C#
if( File.Exists("csharp.net-informations.xls") )
   File.Delete("csharp.net-informations.xls");

   xlWorkBook.SaveAs("csharp.net-informations.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);   
 
Share this answer
 
v2
Comments
Manfred Rudolf Bihy 22-Jan-13 9:06am    
Seems sound advice! :)
fjdiewornncalwe 22-Jan-13 9:10am    
Thanks, Manfred.
Have a look at this previous solution: Saving an excel file without prompt[^].

Cheers!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900