Get Excel

The default Excel document

The following code will need to download "EPPlus.Core"

            var file = Directory.GetCurrentDirectory() + "\\Demo.xlsx";
            using (var source = System.IO.File.OpenRead(file))
            using (var excel = new OfficeOpenXml.ExcelPackage(source))
            {
                excel.Workbook.Worksheets[1].Cells[3, 1].Value = 123;
                excel.Workbook.Worksheets[1].Cells[3, 2].Value = 张三;
                excel.Workbook.Worksheets[1].Cells[3, 3].Value = 29;
                var newfile = Directory.GetCurrentDirectory() + "\\new.xlsx";
                var newfileinfo = new FileInfo(newfile);
                excel.SaveAs(newfileinfo);
            }

Completion will generate the following Excel

 

Guess you like

Origin www.cnblogs.com/ljknlb/p/10964443.html