Re: Saving Excel File
Hugh Brown <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
Okay, Workbook.SaveAs(FileName); Steve Abaffy <[email protected]> wrote: There is no SaveAs Method for the ExcelObjOut. -----Original Message----- Sent: Tuesday, March 27, 2007 12:53 PM To: [email protected] Subject: Re: [DOTNET-WINFORMS] Saving Excel File Try: ExcelObjOut.SaveAs(NewFileName); Steve Abaffy wrote: I have the following code _Application ExcelObjOut = new ApplicationClass(); Workbooks workbooks = ExcelObjOut.Workbooks; _Workbook Workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet); _Worksheet Sheets = (_Worksheet)Workbook.ActiveSheet; Range Range; //NewFile name is generated from an OpenDialogBox FileName so the path is included NewFileName = FileName.Substring(0,FileName.IndexOf(".")) + Processed.xls"; //Add stuff to NewFile (This works fine) // This line does not save the new file as NewFileName it asked me to save Sheet1 opens up a save dialog box and allows me to save the file. ExcelObjOut.Save(NewFileName); // Then this line throws an exception that it can't find the NewFileName file. ExcelObjOut.Quit(); So the question I guess is how do you save a new Excel file that is being generated on the fly after you get done putting your values in it? Thanks