Click here to Skip to main content
12,624,887 members (37,144 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
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;

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 22-Jan-13 1:24am
Updated 22-Jan-13 2:09am
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
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);   
  Permalink  
v2
Comments
Manfred R. Bihy 22-Jan-13 9:06am
   
Seems sound advice! :)
Marcus Kramer 22-Jan-13 9:10am
   
Thanks, Manfred.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Have a look at this previous solution: Saving an excel file without prompt[^].

Cheers!
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161128.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100