如果这是一个非常愚蠢的问题,我很抱歉。我有一个函数可以打开Excel(我用它作为模板(,将文本添加到单元格中,然后导出到不同路径上的PDF,但由于某种原因,xlMedicoes.Visible = false
和xlMedicoes.Visible = false
命令似乎不起作用,我仍然会得到一个";是否保存对此文档所做的更改"窗口弹出。我是一个新手,所以任何帮助都将不胜感激。
xlMedicoes = new Excel.Application();
xlWorkBook = xlMedicoes.Workbooks.Open("C:\Verificacao de Quadros Eletricos\EPLAF\OF127_MEDICOES_EPLAF");
xlWorkSheet = xlWorkBook.Worksheets["Folha1"];
xlMedicoes.Visible = false;
xlMedicoes.UserControl = false;
xlWorkSheet.Cells[13, 9].Value += dateTimePicker1.Text;
string Directory = "C:\Verificacao de Quadros Eletricos\EPLAF\" + textBox4.Text + "\" + textBox3.Text + "\OF127_MEDIÇÕES_" + dateTimePicker1.Text;
xlWorkBook.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, Directory);
xlWorkBook.Close();
xlMedicoes.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlMedicoes);
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkBook);
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkSheet);
}
尝试
xlWorkBook.Close(false);
而不是CCD_ 3。这应该会在不询问的情况下放弃任何更改。