Skip to content

Fix table rendering when table has background style property instead … #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions HtmlToOpenXml.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlToOpenXml", "src\Html2OpenXml\HtmlToOpenXml.csproj", "{EF700F30-C9BB-49A6-912C-E3B77857B514}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{58520A98-BA53-4BA4-AAE3-786AA21331D6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{84EA02ED-2E97-47D2-992E-32CC104A3A7A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlToOpenXml", "src\Html2OpenXml\HtmlToOpenXml.csproj", "{EF700F30-C9BB-49A6-912C-E3B77857B514}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "examples\Demo\Demo.csproj", "{A1ECC760-B9F7-4A00-AF5F-568B5FD6F09F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlToOpenXml.Tests", "test\HtmlToOpenXml.Tests\HtmlToOpenXml.Tests.csproj", "{CA0A68E0-45A0-4A01-A061-F951D93D6906}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlToOpenXml.Tests", "test\HtmlToOpenXml.Tests\HtmlToOpenXml.Tests.csproj", "{CA0A68E0-45A0-4A01-A061-F951D93D6906}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -24,7 +24,6 @@ Global
{EF700F30-C9BB-49A6-912C-E3B77857B514}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF700F30-C9BB-49A6-912C-E3B77857B514}.Release|Any CPU.Build.0 = Release|Any CPU
{A1ECC760-B9F7-4A00-AF5F-568B5FD6F09F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1ECC760-B9F7-4A00-AF5F-568B5FD6F09F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1ECC760-B9F7-4A00-AF5F-568B5FD6F09F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1ECC760-B9F7-4A00-AF5F-568B5FD6F09F}.Release|Any CPU.Build.0 = Release|Any CPU
{CA0A68E0-45A0-4A01-A061-F951D93D6906}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down
13 changes: 6 additions & 7 deletions examples/Demo/Demo.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net35;net40;net46;netstandard1.4</TargetFrameworks>
<OutputType>Exe</OutputType>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="System.Diagnostics.Process" Version="4.3.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.7.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Html2OpenXml\HtmlToOpenXml.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\*" />
</ItemGroup>

</Project>
14 changes: 10 additions & 4 deletions src/Html2OpenXml/Collections/TableStyleCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,17 @@ public void ProcessCommonAttributes(HtmlEnumerator en, IList<OpenXmlElement> run

var colorValue = en.StyleAttributes.GetAsColor("background-color");

if (colorValue.IsEmpty) //We do a first try, if it's empty the background-color, I try it with background
{
colorValue = en.StyleAttributes.GetAsColor("background");
}

//
// "background-color" is also handled by RunStyleCollection which duplicate this attribute (bug #13212).
// Also apply on <th> (issue #20).
// As on 05 Jan 2018, the duplication was due to the wrong argument passed during the td/th processing.
// It was the runStyle and not the containerStyle that was provided. The code has been removed as no more useful
if (colorValue.IsEmpty) colorValue = en.Attributes.GetAsColor("bgcolor");
// Also apply on <th> (issue #20).
// As on 05 Jan 2018, the duplication was due to the wrong argument passed during the td/th processing.
// It was the runStyle and not the containerStyle that was provided. The code has been removed as no more useful
if (colorValue.IsEmpty) colorValue = en.Attributes.GetAsColor("bgcolor");
if (!colorValue.IsEmpty)
{
containerStyleAttributes.Add(
Expand Down
28 changes: 17 additions & 11 deletions src/Html2OpenXml/HtmlToOpenXml.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard1.4</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net35;net40;net46;netstandard1.4</TargetFrameworks>
Expand All @@ -8,7 +7,7 @@
<AssemblyName>HtmlToOpenXml</AssemblyName>
<RootNamespace>HtmlToOpenXml</RootNamespace>
<PackageId>HtmlToOpenXml.dll</PackageId>
<Version>2.0.1</Version>
<Version>2.0.1.1</Version>
<PackageIconUrl>https://github.com/onizet/html2openxml/raw/dev/docs/images/Home_h2oxnuget.png</PackageIconUrl>
<Copyright>Copyright 2009-2018</Copyright>
<PackageReleaseNotes>For long-time follower, this is the next major release version since 1.6.
Expand All @@ -31,26 +30,31 @@ You can see release note here: https://github.com/onizet/html2openxml/releases
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<PackageLicenseUrl>https://github.com/onizet/html2openxml/blob/master/License.txt</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/onizet/html2openxml</PackageProjectUrl>
<RepositoryUrl></RepositoryUrl>
<RepositoryUrl>
</RepositoryUrl>
<Description>A library to convert simple or advanced html to plain OpenXml document</Description>
<Authors>Olivier Nizet</Authors>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>HtmlToOpenXml.snk</AssemblyOriginatorKeyFile>
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
<FileVersion>2.0.1.1</FileVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<ProjectGuid>{47B5D391-1B58-4162-9380-AB7D3BE6511A}</ProjectGuid>
</PropertyGroup>

<!--
Since this project supports multiple configurations which don't all have the same surface area, the following define
constants are used to conditionally compile features:
FEATURE_NETHTTP : System.Net.WebClient is available in the platform
FEATURE_REFLECTION : System.Reflections is using Pre .NetCore API
-->

<ItemGroup Condition=" '$(TargetFramework)' == 'net35' OR '$(TargetFramework)' == 'net40' OR '$(TargetFramework)' == 'net46' ">
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>

<!-- .NET Framework < 4.6 -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'net35' OR '$(TargetFramework)' == 'net40' ">
<DefineConstants>$(DefineConstants);FEATURE_NETHTTP;FEATURE_REFLECTION</DefineConstants>
Expand All @@ -62,17 +66,20 @@ You can see release note here: https://github.com/onizet/html2openxml/releases
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.4' ">
<DefineConstants>$(DefineConstants);NET_CORE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.7.2" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
<PackageReference Include="System.Net.Http">
<Version>4.3.0</Version>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.4'">
<PackageReference Include="System.Net.Http">
<Version>4.3.0</Version>
Expand All @@ -81,5 +88,4 @@ You can see release note here: https://github.com/onizet/html2openxml/releases
<Version>4.3.0</Version>
</PackageReference>
</ItemGroup>

</Project>