المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : create excell file



C# Programming
06-15-2009, 07:00 PM
Hello,
I am using microsoft.office.interop.excell to write to excell file.
But i have a problem of saving it.
If i do workbook.saveas and the file exists it asks me if to save it and it rewrites me it (removes the old data).
if i specify it to open a file when i create the workbook:
Microsoft.Office.Interop.Excel.Workbook objBook = ExcelApp.Workbooks.Open(@"c:\Focus Report\123.xls", 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
and the file doesn't exist it cannot save and throws and exception that the file wasn't found.

So how can i save the file (create if not exist and save it (not rewrite) it if exist)?