Skip to content

Commit 3a1f60d

Browse files
Upgrade NPOI from 2.5.6 to 2.7.3 to fix issues opening Excel files with PivotTables
1 parent 38cb77e commit 3a1f60d

File tree

6 files changed

+10
-14
lines changed

6 files changed

+10
-14
lines changed

dotnet/src/dotnetcore/GxOffice/GxOffice.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242

4343
<ItemGroup>
44-
<PackageReference Include="NPOI" Version="2.5.6" />
44+
<PackageReference Include="NPOI" Version="2.7.3" />
4545
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
4646
</ItemGroup>
4747

dotnet/src/dotnetframework/GxOffice/GxOffice.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99
<ItemGroup>
1010
<PackageReference Include="EPPlus" Version="4.5.3.2" />
11-
<PackageReference Include="NPOI" Version="2.6.0" />
11+
<PackageReference Include="NPOI" Version="2.7.3" />
1212
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
1313
</ItemGroup>
1414

dotnet/src/dotnetframework/GxOffice/poi/hssf/ExcelCells.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,14 @@ public string GetHyperlink()
213213

214214
public DateTime GetDate()
215215
{
216-
DateTime returnValue = DateTimeUtil.NullDate();
217216
try
218217
{
219-
returnValue = pCells[1].DateCellValue;
218+
return pCells[1].DateCellValue ?? DateTimeUtil.NullDate();
220219
}
221220
catch (Exception)
222221
{
223222
throw new ExcelException(7, "Invalid cell value");
224223
}
225-
return returnValue;
226224
}
227225

228226
public bool SetTextImpl(string value)
@@ -395,7 +393,7 @@ private string GetFormulaType()
395393
{
396394
try
397395
{
398-
DateTime dVal = pCells[1].DateCellValue;
396+
DateTime dVal = pCells[1].DateCellValue ?? DateTime.MinValue;
399397
if (dVal != DateTime.MinValue)
400398
{
401399
return "D";
@@ -832,7 +830,7 @@ private void FitColumnWidth(int i, int data)
832830
{
833831
if (fitColumnWidth)
834832
{
835-
int colW = pSelectedSheet.GetColumnWidth((int)(i + colStartIdx - 1));
833+
double colW = pSelectedSheet.GetColumnWidth((int)(i + colStartIdx - 1));
836834
if ((256 * data) > colW)
837835
{
838836
colW = (short)(256 * data);

dotnet/src/dotnetframework/GxOffice/poi/hssf/ExcelWorksheet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public bool Hidden
3535
if (_sheet != null)
3636
{
3737
HSSFWorkbook wb = (HSSFWorkbook)_sheet.Workbook;
38-
wb.SetSheetHidden(SheetIndex(wb), value ? NPOI.SS.UserModel.SheetState.Hidden : NPOI.SS.UserModel.SheetState.Visible);
38+
wb.SetSheetVisibility(SheetIndex(wb), value ? NPOI.SS.UserModel.SheetVisibility.Hidden : NPOI.SS.UserModel.SheetVisibility.Visible);
3939
}
4040
}
4141
}

dotnet/src/dotnetframework/GxOffice/poi/xssf/ExcelCells.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,14 @@ public string GetHyperlink()
215215

216216
public DateTime GetDate()
217217
{
218-
DateTime returnValue = DateTimeUtil.NullDate();
219218
try
220219
{
221-
returnValue = pCells[1].DateCellValue;
220+
return pCells[1].DateCellValue ?? DateTimeUtil.NullDate();
222221
}
223222
catch (Exception)
224223
{
225224
throw new ExcelException(7, "Invalid cell value");
226225
}
227-
return returnValue;
228226
}
229227

230228
public bool SetTextImpl(string value)
@@ -397,7 +395,7 @@ private string GetFormulaType()
397395
{
398396
try
399397
{
400-
DateTime dVal = pCells[1].DateCellValue;
398+
DateTime dVal = pCells[1].DateCellValue ?? DateTime.MinValue;
401399
if (dVal != DateTime.MinValue)
402400
{
403401
return "D";
@@ -868,7 +866,7 @@ private void FitColumnWidth(int i, int data)
868866
{
869867
if (fitColumnWidth)
870868
{
871-
int colW = pSelectedSheet.GetColumnWidth((int)(i + colStartIdx - 1));
869+
double colW = pSelectedSheet.GetColumnWidth((int)(i + colStartIdx - 1));
872870
if ((256 * data) > colW)
873871
{
874872
colW = (short)(256 * data);

dotnet/src/dotnetframework/GxOffice/poi/xssf/ExcelWorksheet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public bool Hidden
3535
if (_sheet != null)
3636
{
3737
XSSFWorkbook wb = (XSSFWorkbook)_sheet.Workbook;
38-
wb.SetSheetHidden(SheetIndex(wb), value ? NPOI.SS.UserModel.SheetState.Hidden : NPOI.SS.UserModel.SheetState.Visible);
38+
wb.SetSheetVisibility(SheetIndex(wb), value ? NPOI.SS.UserModel.SheetVisibility.Hidden: NPOI.SS.UserModel.SheetVisibility.Visible);
3939
}
4040
}
4141
}

0 commit comments

Comments
 (0)