Skip to content

Commit 5636fb8

Browse files
committed
fixed excel file manager delete unused rows
1 parent 650f91c commit 5636fb8

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Example/Data/Context.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Example.Data.Entities;
22
using FileContextCore;
3+
using FileContextCore.StoreManager;
34
using Microsoft.EntityFrameworkCore;
5+
using OfficeOpenXml;
46

57
namespace Example.Data
68
{
@@ -41,6 +43,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
4143
// optionsBuilder.UseFileContextDatabase(location: @"D:\t");
4244

4345
//Excel
46+
// ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
4447
// optionsBuilder.UseFileContextDatabase<EXCELStoreManager>(databaseName: "test");
4548
}
4649

Example/Data/NewContext.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Microsoft.EntityFrameworkCore;
22
using Example.Data.Entities;
33
using FileContextCore;
4+
using FileContextCore.StoreManager;
5+
using OfficeOpenXml;
46

57
namespace Example.Data
68
{
@@ -35,7 +37,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
3537
//optionsBuilder.UseFileContext("csv");
3638

3739
//Excel
38-
//optionsBuilder.UseFileContext("excel");
40+
// ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
41+
// optionsBuilder.UseFileContextDatabase<EXCELStoreManager>(databaseName: "excel");
3942
}
4043

4144
protected override void OnModelCreating(ModelBuilder modelBuilder)

FileContextCore/StoreManager/EXCELStoreManager.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ private void DeleteUnusedRows(int lastRow)
173173
if (_worksheet.Dimension.Rows >= lastRow)
174174
{
175175
int count = _worksheet.Dimension.Rows - lastRow;
176-
_worksheet.DeleteRow(lastRow + 1, count);
176+
if (count > 0)
177+
{
178+
_worksheet.DeleteRow(lastRow + 1, count);
179+
}
177180
}
178181
}
179182
}

0 commit comments

Comments
 (0)