Skip to content
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

Enhanced Table Cell content #12

Open
wants to merge 3 commits into
base: vNext
Choose a base branch
from
Open

Conversation

kevlyons
Copy link

@kevlyons kevlyons commented Aug 1, 2019

I needed to have optional cell values and more powerful retrieval instead of immediate child elements.

TableCellContent

tomjebo and others added 3 commits February 4, 2019 22:15
add archive message
point to ericwhitedev/open-xml-powertools
@@ -717,10 +717,18 @@ static object ContentReplacementTransform(XNode node, XElement data, TemplateErr
XElement paragraph = tc.Elements(W.p).FirstOrDefault();
XElement cellRun = paragraph.Elements(W.r).FirstOrDefault();
string xPath = paragraph.Value;
bool cellIsOptional = false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this could be simplified to:

    var xPath = paragraph.Value;
    var optionalString = "";
    try
    {
        var xElement = XElement.Parse(xPath);
        xPath = (string)xElement.Attribute(PA.Select);
        optionalString = (string)xElement.Attribute(PA.Optional);
    }
    catch { }

    try
    {
        newValue = EvaluateXPathToString(d, xPath, optionalString?.ToLower() == "true");
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants