i am trying to run the following code :
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Ad开发者_如何转开发d(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlWorkSheet.Cells[1, 1] = "http://csharp.net-informations.com";
xlWorkBook.SaveAs("csharp-Excel.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
Application executes without any error. but i cannot see the excel sheet anywhere in my computer. Please help me.
i am following this tutorial.
Source:
http://csharp.net-informations.com/excel/csharp-create-excel.htm
In your SaveAs() method you supply only a filename but no path. Thus the document will get saved to your default documents folder which is likely the My Documents folder of the user running the app.
精彩评论