I have a programming question:
I have a NotesDocumentCollection.
I need to sort this collection and export it to excel. The exported collection should be sorted into two groups - one called Enhancements and the other called Bugs (dependent on the value of a field called “type” on the documents being exported). Within those groups each type has a priority (another field on the documents)1, 2, or 3 on it. Within each group they should be sorted by priority. I’m wondering the best way to do this. I have the export to excel and I can think of ways to do this - e.g. make six arrays each corresponding to one group E1,E2,E3,B1…etc. and then append them together - I was wondering if someone could give me ideas about the best/most efficient way to do this.
Thank you in advance,
Leonardo
Subject: Most efficient sort
If you are doing this export often, a view could be used. You can then iterate through it with NotesViewEntries to get them in that sorted order. You could also do the sorting in LotusScript, using some sorting algorithm (insert sort, quick sort etc), but that may take some time depending on how many entries / documents you have.
johan@kanngard.net
http://dev.kanngard.net
Subject: Most efficient sort
Since it sounds like the sort criteria is static I have to second iterating through a view as your most efficient option.
Subject: RE: Most efficient sort
I can’t iterate through a view because the document collection is created through a search form (where they can select docs created after “x” date, assigned to John Doe, etc.).
Subject: RE: Most efficient sort
Once you have the document collection, drop the documents into a folder with the right sort criteria. Then read the folder contents in order.
Remember to clear out the folder before you try to use it again for the next search.
Subject: Most efficient sort
Create temporary documents from the notesdocumentcollection with the fields which need to be exported to excel. Generate a unique key and stamp it on all the newly created temporary documents.
Create a view which will use the temporary form with the unique key as 1st categorized column. Create additional columns are required in excel i.e
2nd column → categorized ascending > field “Type”
3rd column → categorized acsending > field “Priority”
now you can use NotesViewNavigator class and retrive all the entries based on the unique key i.e
Dim viewNav As NotesViewNavigator
Dim entry As NotesViewEntry
Set viewNav = view.CreateViewNavFromCategory(uniqueString)
Set entry = viewNav.GetFirst
While Not entry Is Nothing
For j = 1 To Ubound(entry.ColumnValues)
msgbox entry.ColumnValues(j)
’ you can check the IndentLevel if you are looking for a particualar value
Next
Set entry = viewNav.GetNext(entry)
Wend
Once done, you could delete the temporary documents or create a scheduled agent to do so.
cheers !!
Ashish
Subject: Most efficient sort
Seems pretty straigt forward to me (assuming you are using lotusscript + COM to export to Excel):
-
Walk the collection, and put the column values it in the approriate group (different worksheets?) on your excel document.
-
Let excel do the sorting by calling the built in sort function.
Any sorting of documents you’ll do in your own agent will be less efficiënt than the excel sort.
cheers,
Bram