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.Sheets["Sheet1"];xlWorkSheet.name = "Exported Data";xlWorkSheet.Cells[1,1] = "Demo";xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);xlWorkBook.SaveAs("filename.xls",Excel.XlfileFormat.xlWorkbooknormal,misValue,Excel.XlSaveAsAccessMode.xlExclusive,misValue);xlWorkBook.Close(true,misValue);xlApp.Quit();System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkSheet);System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkBook);System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);xlWorkSheet = null;xlWorkBook = null;xlApp = null;GC.Collect();解决方法 您始终可以使用显示xlApp
xlApp.Visible = true;总结
以上是内存溢出为你收集整理的C#创建Excel(完成)然后显示/打开它?救命全部内容,希望文章能够帮你解决C#创建Excel(完成)然后显示/打开它?救命所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)