Click here to Skip to main content
Rate this: bad
good
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
Edited 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 at 22-Jan-13 9:06am
   
Seems sound advice! :)
Marcus Kramer at 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
0 Maciej Los 337
1 DamithSL 305
2 ridoy 264
3 OriginalGriff 208
4 George Jonsson 140
0 OriginalGriff 7,968
1 DamithSL 6,179
2 Sergey Alexandrovich Kryukov 5,524
3 Maciej Los 5,438
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2014
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