views:

52

answers:

1

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.Add(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

+1  A: 

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.

Keith