Browse Source

Fixed a bug with TableStyles, thanks for reporting this Przemek.

master
coffeycathal_cp 13 years ago
parent
commit
019f584e9a
1 changed files with 8 additions and 9 deletions
  1. 8
    9
      DocX/Table.cs

+ 8
- 9
DocX/Table.cs View File

default: break; default: break;
} }
XDocument style_doc;
PackagePart word_styles = Document.package.GetPart(new Uri("/word/styles.xml", UriKind.Relative));
using (TextReader tr = new StreamReader(word_styles.GetStream()))
style_doc = XDocument.Load(tr);
if (Document.styles == null)
{
PackagePart word_styles = Document.package.GetPart(new Uri("/word/styles.xml", UriKind.Relative));
using (TextReader tr = new StreamReader(word_styles.GetStream()))
Document.styles = XDocument.Load(tr);
}
var tableStyle = var tableStyle =
( (
from e in style_doc.Descendants()
from e in Document.styles.Descendants()
let styleId = e.Attribute(XName.Get("styleId", DocX.w.NamespaceName)) let styleId = e.Attribute(XName.Get("styleId", DocX.w.NamespaceName))
where (styleId != null && styleId.Value == val.Value) where (styleId != null && styleId.Value == val.Value)
select e select e
select e select e
).First(); ).First();
style_doc.Element(XName.Get("styles", DocX.w.NamespaceName)).Add(styleElement);
using (TextWriter tw = new StreamWriter(word_styles.GetStream(FileMode.Create)))
style_doc.Save(tw, SaveOptions.None);
Document.styles.Element(XName.Get("styles", DocX.w.NamespaceName)).Add(styleElement);
} }
} }
} }

Loading…
Cancel
Save