sergey-tihon / Clippit

Fresh PowerTools for OpenXml
https://sergey-tihon.github.io/Clippit/
MIT License
50 stars 19 forks source link

DocumentAssembler: Is it possible to to have conditional Table Row? (unrelated) Hidden methods? #67

Open Marcel0024 opened 1 year ago

Marcel0024 commented 1 year ago

Hi, i have 2 questions i can't find documentation on. (Even the original repos)

  1. Is it possible to have a conditional Table Row? For example:

image

I don't want to show Order Date row if it's empty. I can add another boolean into the model indicating if it needs to be shown or not. But i can't figure out if you can add a conditional to the table.

  1. In Another issue i saw something like thisthis:

<Conditional Select="count(./Orders/Order) > 0" Match="True" />

I can't find any documentation on count(..)? Where does it come from? And more importantly, what else is there?

sergey-tihon commented 1 year ago

Sorry, I also do not know. I have never used this part of PowerTools.

The only thing I can suggest is to look at the source code.

MalcolmJohnston commented 3 months ago

A simple way that you can do this is:

  1. Split your table into two tables
  2. Wrap a Conditional around only the order date row

You'd end up with something like this:

<Repeat Select="Orders/Order" />

Product: <Content Select="./ProductDescription" />
Quantity: <Content Select="./Quantity" />

<Conditional Select="count(./OrderDate) > 0" Match="True" />

Order Date: <Content Select="./OrderDate" />

<EndConditional />

<EndRepeat />

If you don't add any whitespace between the rows then Word should render this as a single table.