public void TestNpoiExcelExport() { ServiceCollection services = new ServiceCollection(); services.AddNpoiOffice(); IServiceProvider serviceProvider = services.BuildServiceProvider(); IOffice office = serviceProvider.GetRequiredService <IOffice>(); string fileName = Guid.NewGuid().ToString(); office.ExportToExcel(GetDemoDatas(), $"{fileName}.xlsx", new ExportOption() { SheetName = "sheet3" }); Assert.IsTrue(File.Exists($"{fileName}.xlsx")); }
public void TestNpoiExcelImport() { ServiceCollection services = new ServiceCollection(); services.AddNpoiOffice(); IServiceProvider serviceProvider = services.BuildServiceProvider(); IOffice office = serviceProvider.GetRequiredService <IOffice>(); string fileName = Guid.NewGuid().ToString(); office.ExportToExcel(GetDemoDatas(), $"{fileName}.xlsx", new ExportOption() { SheetName = "sheet3" }); var result = office.ImportFromExcel <DemoData>($"{fileName}.xlsx"); Assert.IsNotNull(result); Assert.IsTrue(result.Any()); }