Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want-> When I open a excel sheet than it should auto save to my current working directory. and its naming always according to date like Today: sheet462017

What I have tried:

Microsoft.Office.Interop.Excel.Application excelApplication = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook excelWorkBook = excelApplication.Workbooks.Add();
//Microsoft.Office.Interop.Excel.Worksheet wkSheetData = excelWorkBook.ActiveSheet;
string workbookPath = System.IO.Directory.GetCurrentDirectory() + "\\Excl.xlsx";
excelWorkBook.SaveAs(workbookPath);
Posted
Updated 5-Apr-17 21:35pm
Comments
Karthik_Mahalingam 6-Apr-17 3:09am    
what do you mean by "current working directory" ?
project root folder?
Parmendra choudhary 6-Apr-17 3:15am    
Yes ..\bin\Debug

1 solution

try
string path = System.Web.Hosting.HostingEnvironment.MapPath("~/bin/debug");
string workbookPath = System.IO.Path.Combine(path, "Excl.xlsx");
 
Share this answer
 
Comments
Parmendra choudhary 6-Apr-17 3:48am    
Karthik, I want to save my current open excel file. How I find my current open file.
I thik We need to use some excel property or some system related property.

I want: When I export any excel from my windows project then exported file auto save as my current directory (bin\debug)
Karthik_Mahalingam 6-Apr-17 3:50am    
then write the code in the windows app in such a way that it saves the file in the "bin\debug" folder of asp application
Parmendra choudhary 6-Apr-17 3:53am    
Can I write any script at the time of automation.
Karthik_Mahalingam 6-Apr-17 4:03am    
am not sure on how your app works.

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