I would like to read my Word.ListFormat by hierarchy level in docx file by Word.Interop.
for Example, the below list not applied by outline or/and indent to read by hierarchy
1. Item 1 of Level 1 List
a. Item 1 of Level 2 List
b. Item 2 of Level 2 List
c. Item 2 of Level 2 List
2. Item 2 of Level 1 List
a. Item 1 of Level 2 List
1. Item 1 of Level 3 List
2. Item 1 of Level 3 List
b. Item 2 of Level 2 List
c. Item 2 of Level 2 List
3. Item 3 of Level 1 List
My Expectation to read the List by hierarchy, I don't want to read by sequence of paragraph.
First reading: Item 1 of Level 1 List
Second reading: Item 2 of Level 1 List
Third reading: Item 3 of Level 1 List
Once reading complete the Level 1, then need to read Level 2 list.
Here, I have attached the sample screen shot of docx list file.
Thanks to all for supporting,
I found the answer of the question.
foreach (Word.Paragraph firstItem in document.Content.ListParagraphs.OfType<Word.Paragraph>().Reverse())
{
if (firstItem.Range.ListFormat.List != null)
{
foreach (Word.Paragraph item in firstItem.Range.ListFormat.List.ListParagraphs)
{
}
}
}
Related
Suppose that my query is 'A' for the following table. I want to find any value of 'c_index' corresponding to 'A', and then get all the rows of the table which have the corresponding values of 'c_index'.
Node Name
c_index
A
1
B
1
A
2
C
2
B
3
D
3
C
4
E
4
Values of 'c_index' corresponding to 'A' are {1, 2}. So the desired result of the filter is:
Node Name
c_index
A
1
B
1
A
2
C
2
How can I do this filtration in Tableau?
What I tried is:
Defined a filter on 'c_index' (i.e. drag and drop 'c_index' to the filter shelf). And then I tried to define the condition for the filter as: [Node Name] = 'A'.
But it throws an error: "The formula must be an aggregate calculation or refer only to this field".
First Join the (data) table with itself on the column which you want to return linked values. In the example c_index.
Now there will two same data sets in your data pane.
Add node from first dataset to filter, node from second dataset to view and c_index from anyone to view. You'll get what you desire. See GIF below
I want to import all products filtering these they applied all 3 criteria:
1) they are in stock (DIM)
2) stock is more than 3 pcs (stock_indicator)
3) and they belong to one (any) of these groups 1 or 4
I want all 3 criteria, but in 3rd any of these options
i.e.:
/product[dim1[1] = "1" and stock_indicator[1] > 3 and group[1] = "1" or group/category/id[1] = "4"]
The above does not returns any product, like no product have all these requirements.
What am I doing wrong?
Dim = availability
XML sample:
/product[dim1[1] = "1" and stock_indicator[1] > 3 and group[1] = "1" or group/category/id[1] = "4"]
First of all your XPath assumes that all product elements are at root level, which would not make for a well-formed XML document; the all should be wrapped in some element.
If that is no problem in your environment (since we do not know the whole setup from your question) probably the most prominent problem in your XPath is that you try to compare the value of stock_indicator against a xs:integer but in fact your data sample encodes them as xs:string.
Consequently
stock_indicator[1] > 3
will always return falseā¦
Try
stock_indicator[1]/number() > 3
or
number(stock_indicator[1]) > 3
instead.
Nevertheless depending on the data structure (e.g. multiple stock_indicatorelements in one product [whatever that might mean]) this could return false positives.
You can use the following XPath to filter the products :
//product[availability="1"][stock_indicator>3][group/id=1 or group/id=4]
// at the beginning as stated by #Benjamin W. Bohl to catch all products
availability is used instead of "Dim"
cleaner syntax used for predicates
no position indexes used ([1]) assuming you only have 1 availability, 1 stock_indicator, 1 id per group in each product
XML used to test.
XPath :
XML is filtered (2 of the 4 products fulfill the conditions) :
Okay, so I have a name list where I write names in. Those names go in alphabetical order in another list where I give the names numbers. But whenever I add or remove names, cell shift places but the numbers remain the same, so if Adam had 1 1 1 1 and Bobby 2 2 2 2, by adding Ben he will take Bobby's place (because of the alphabetical order) and have 2 2 2 2 while Bobby will have 0 0 0 0. How do I make the numbers go after the name?
Photos with the examples (watch where appleboy comes in):
The sheet: https://docs.google.com/spreadsheets/d/1rH-4wzAzgOZ31jfH8MPkFnLCLzET3tfiGQrxaUpIg6Y/edit#gid=2041472100
you don't have a lot of options...
you can either have your names in order as you add them, then assign numbers to them (both actions on the same sheet) and then use simple SORT formula in sheet2 to get alphabetically sorted those names.
=SORT(sheet1!A2:F)
the 2nd option is to set up a lookup table on some helper sheet3 and then use ArrayFormula with VLOOKUP to match the ID (unique names). and then in B2:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A, sheet3!A:F, {2,3,4,5,6}, 0)))
the 3rd option would be to use a sorting script for a specified range
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("ChangeSheetNameHere");
var range = sheet.getRange("A2:Z");
function onEdit(e) {
range.sort([{column: 1, ascending: true}]);
}
I am attempting to create a pug mixin that can handle different formatting depending on the length of the generated list. I have it able to accept unlimited values, and can generate a single list no problem.
When I try to sort the items by index in order to create multiple lists, the code either generates a new <ul> for each <li> or nothing at all for the longer list formatting.
How can I make it so if the length of the items array is greater than 5, it puts the first 5 items in list 1 and the rest in the second list?
Code:
mixin panelList(...items)
if items.length < 6
ul.list-unstyled.col.col-12.col-lg-12.d-none.d-lg-inline
each item in items
li.list-item.my-lg-1= item
else
each item in items
.row.row-12
while index < 6
ul.list-unstyled.col.col-12.col-lg-6.offset-sm-4.offset-md-0.offset-lg-0.d-none.d-lg-inline
li.list-item.my-lg-1= item
while index > 5
ul.list-unstyled.col.col-12.col-lg-12.d-none.d-lg-inline
li.list-item.my-lg-1= item
mixin panelList(...items)
if items.length < 6
ul.list-unstyled.col.col-12.col-lg-12.d-none.d-lg-inline
each item in items
li.list-item.my-lg-1= item
else
each item in items
.row.row-12
while index < 6
ul.list-unstyled.col.col-12.col-lg-6.offset-sm-4.offset-md-0.offset-lg-0.d-none.d-lg-inline
li.list-item.my-lg-1= item
while index > 5
ul.list-unstyled.col.col-12.col-lg-12.d-none.d-lg-inline
li.list-item.my-lg-1= item
implemented via:
+panelList("this", "is", "working", "great") works fine
problem is with a list like:
+panelList("this", "is", "not", "working", "quite", "as", "intended", "yet")
I have tried sorting by % but it generates a new <ul> for each item. I have tried using item.index and index. I have tried using for and if instead of while before index < 6 also.
Here is the algorithm which returns the position(in form of a callback) at which an item can be inserted and also update the position of the previous items.
Put the item into infinite length array (assumed), 0<=index<INFINITY,
and for empty array largest_index_occupied = 0. ALSO largest_index_occupied is dynamically retrieved from database.(assumed). No two item can share same index. No item must be lost during any operation. indexes are in increasing order.
1. if index not provided OR index provided is greater than largest_index_occupied then put item at index : largest_index_occupied+5;
2. If index provided AND less than equals to largest_index_occupied, :
a. if (No other item already exists at that index) : simply put the item at that index
b. otherwise (means if a item already exists at that index) : increase the index of all items by one untill we get an empty index. and put the new item at the index actually passed by user(which must be empty now).
2.b example :
say - shows empty index.
previous state
0 - - - - 5 6 7 - - 10
a - - - - b c d - - e
input at index : 5,f
new state :
0 - - - - 5 6 7 8 - 10
a - - - - f b c d - e
Noe f's new index is 5.
My requirement is to write a code for the above in combination of async,recursion and IO operation (db update - of the index of items in case of 2.b) in nodejs.
i am expecting next(err,indexToBeInserted); callback that has to called only after all the updation has taken place.
My function block goes here :
toInsert(mongooseModel,next,indexToBeInserted) {
// async code goes here.
}
ps : if you have any better solution please share.