G
Guest
Hi!
I've worked hard to get my data into Excel from a bunch of text files. I've
opened Excel and dumped the data in. I want to save the workbook/spreadsheet
but have not set a file name yet in the coding.
Running the below code I get a Dialog box that prompts for a file name and
path. You know the usual. I don't want this. I want to automate the entire
process. I want to create a filename that have MVC <Date>.xls.
If I cancel the dialog box I get an exception. If I put in a file name I
get my file (named as above) but also an additional file book1.xls for
example.
Is there a way to supress the dialog box and just save the file in the
naming convention that I want???
//Set default path and filename.
excel.DefaultFilePath = (@"C:\");
DateTime dtCurrTime = DateTime.Now;
string ExcelFile = "MVC " + dtCurrTime.ToShortDateString() + ".xls";
excel.Save(ExcelFile);
excel.Quit(); // Close Excel
Thanks JM
I've worked hard to get my data into Excel from a bunch of text files. I've
opened Excel and dumped the data in. I want to save the workbook/spreadsheet
but have not set a file name yet in the coding.
Running the below code I get a Dialog box that prompts for a file name and
path. You know the usual. I don't want this. I want to automate the entire
process. I want to create a filename that have MVC <Date>.xls.
If I cancel the dialog box I get an exception. If I put in a file name I
get my file (named as above) but also an additional file book1.xls for
example.
Is there a way to supress the dialog box and just save the file in the
naming convention that I want???
//Set default path and filename.
excel.DefaultFilePath = (@"C:\");
DateTime dtCurrTime = DateTime.Now;
string ExcelFile = "MVC " + dtCurrTime.ToShortDateString() + ".xls";
excel.Save(ExcelFile);
excel.Quit(); // Close Excel
Thanks JM