瀏覽代碼

Previously created TableBorder class has an error in setting table border colors. The generated colors are invalid according to the DOCX specification.

Fixed this by using the _Extensions methods.

Patch provided by lckuiper
master
MadBoy_cp 11 年之前
父節點
當前提交
d1eda4f0c7
共有 1 個檔案被更改,包括 4 行新增4 行删除
  1. 4
    4
      DocX/Table.cs

+ 4
- 4
DocX/Table.cs 查看文件

tblBorderType.SetAttributeValue(XName.Get("space", DocX.w.NamespaceName), (border.Space).ToString()); tblBorderType.SetAttributeValue(XName.Get("space", DocX.w.NamespaceName), (border.Space).ToString());
// The color attribute is used for the border color // The color attribute is used for the border color
tblBorderType.SetAttributeValue(XName.Get("color", DocX.w.NamespaceName), ColorTranslator.ToHtml(border.Color));
tblBorderType.SetAttributeValue(XName.Get("color", DocX.w.NamespaceName), border.Color.ToHex());
} }
} }
// If color is not a Color, something is wrong with this attributes value, so remove it // If color is not a Color, something is wrong with this attributes value, so remove it
try try
{ {
b.Color = ColorTranslator.FromHtml(color.Value);
b.Color = ColorTranslator.FromHtml(string.Format("#{0}", color.Value));
} }
catch catch
{ {
tcBorderType.SetAttributeValue(XName.Get("space", DocX.w.NamespaceName), (border.Space).ToString()); tcBorderType.SetAttributeValue(XName.Get("space", DocX.w.NamespaceName), (border.Space).ToString());
// The color attribute is used for the border color // The color attribute is used for the border color
tcBorderType.SetAttributeValue(XName.Get("color", DocX.w.NamespaceName), ColorTranslator.ToHtml(border.Color));
tcBorderType.SetAttributeValue(XName.Get("color", DocX.w.NamespaceName), border.Color.ToHex());
} }
// If color is not a Color, something is wrong with this attributes value, so remove it // If color is not a Color, something is wrong with this attributes value, so remove it
try try
{ {
b.Color = ColorTranslator.FromHtml(color.Value);
b.Color = ColorTranslator.FromHtml(string.Format("#{0}", color.Value));
} }
catch catch
{ {

Loading…
取消
儲存