Browse Source

Merge pull request #89 from swimlane/null-reference-exception-fixes

Fix potential null reference exceptions, bump zip lib version
master
Savorboard 6 years ago
committed by GitHub
parent
commit
cd0ad0cb84
  1. 3
      src/NPOI.OOXML/NPOI.OOXML.csproj
  2. 8
      src/NPOI.OOXML/SS/Converter/ExcelToHtmlConverter.cs
  3. 2
      src/NPOI/NPOI.csproj

3
src/NPOI.OOXML/NPOI.OOXML.csproj

@ -2,7 +2,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<PackageId>DotNetCore.NPOI</PackageId>
<PackageId>DotNetCore.NPOI</PackageId>
<Version>1.2.1</Version>
</PropertyGroup>
<ItemGroup>

8
src/NPOI.OOXML/SS/Converter/ExcelToHtmlConverter.cs

@ -674,8 +674,6 @@ namespace NPOI.SS.Converter
{
style.Append("white-space: pre-wrap; ");
ExcelToHtmlUtils.AppendAlign(style, cellStyle.Alignment);
StylesTable st = ((XSSFWorkbook)workbook).GetStylesSource();
ThemesTable tt = st.GetTheme();
if (cellStyle.FillPattern == FillPattern.NoFill)
{
// no fill
@ -741,7 +739,7 @@ namespace NPOI.SS.Converter
if (workbook is HSSFWorkbook)
{
HSSFColor color = ((HSSFWorkbook)workbook).GetCustomPalette().GetColor(borderColor);
HSSFColor color = ((HSSFWorkbook)workbook).GetCustomPalette()?.GetColor(borderColor);
if (color != null)
{
borderStyle.Append(' ');
@ -758,7 +756,7 @@ namespace NPOI.SS.Converter
}
else
{
XSSFColor color = ((XSSFWorkbook)workbook).GetStylesSource().GetTheme().GetThemeColor(borderColor);
XSSFColor color = ((XSSFWorkbook)workbook)?.GetStylesSource()?.GetTheme()?.GetThemeColor(borderColor);
if (color != null)
{
borderStyle.Append(' ');
@ -785,7 +783,7 @@ namespace NPOI.SS.Converter
if (workbook is HSSFWorkbook)
{
HSSFColor fontColor = ((HSSFWorkbook)workbook).GetCustomPalette().GetColor(font.Color);
HSSFColor fontColor = ((HSSFWorkbook)workbook).GetCustomPalette()?.GetColor(font.Color);
if (fontColor != null)
style.AppendFormat("color:{0}; " ,ExcelToHtmlUtils.GetColor(fontColor) );
}

2
src/NPOI/NPOI.csproj

@ -21,7 +21,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SharpZipLib" Version="1.0.0-rc1" />
<PackageReference Include="SharpZipLib" Version="1.0.0" />
<PackageReference Include="System.Drawing.Common" Version="4.5.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.0" />
</ItemGroup>

Loading…
Cancel
Save