我想打開,並通過使用C#如何關閉excel窗口自動?
更改Excel單元格,它的工作原理,但如果我保存文件,我得到從Excel -.-一個窗口,每次我必須點擊按鈕。看到圖片。
這裏是我的代碼:
foreach (string file in Directory.GetFiles(path))
{
MSExcel.Workbook book1 = null;
MSExcel.Worksheet sheet1;
MSExcel.Range range_A1;
try
{
book1 = app.Workbooks.Open(file);
sheet1 = (MSExcel.Worksheet)book1.Worksheets[1];
range_A1 = sheet1.GetRange(cell);
string content = range_A1.Value2.ToString();
if (content == value || content == value2)
{
range_A1.Value2 = string.Empty;
book1.Save(); // here i save the value
Console.WriteLine(count +" - OPEN AND CHANGE - " + file + " SAVE");
}
else
{
Console.WriteLine(count + " - OPEN - " + file + " NOT SAVE");
}
count++;
}
catch (Exception)
{
count++;
Console.WriteLine(count + " - ERROR FILE " + file);
liste.Add(file);
}
finally
{
book1.Close(false);
}
}
我怎樣才能使它自動?
看看[這裏](http://superuser.com/questions/83199/can not-out-of-compatibility-mode-in-excel-2007),我認爲這可以幫助你。 – 2013-04-22 13:46:22