我使用 EPPlus.dll 作为创建 Excel 工作表的库。但是使用这些代码,我得到了一个错误:Exception thrown: 'System.NullReferenceException' in ExcelReports.cs:line 37
28. String filename = "D:\\" + MonthYear + "_journal.xls";
29. FileInfo template = new FileInfo("D:\\template_journal.xls");
30. if (File.Exists(filename))
31. {
32. File.Delete(filename);
33. }
34. FileInfo newFile = new FileInfo(filename);
35. ExcelPackage pck = new ExcelPackage(newFile, template);
36. ExcelWorksheet journalsheet = pck.Workbook.Worksheets["Journal"];
37. journalsheet.Cells["C1"].Value = "Sample Value";
38. pck.Save();