azurefieldnotes / ReportHTML

47 stars 21 forks source link

Problems with GroupHeaders #11

Open GitHubBJW opened 6 years ago

GitHubBJW commented 6 years ago

I created a table in a report as follows: $rpt += Get-HTMLContentTable -ArrayofObjects ($ArrItems | Select-Object EventId, Time, WinLog, EntryType, Source, Message) -GroupBy EventId The grouping worked fine when the report was simple, but when one of the items, specifically the "Message" property was very large and complex the report ended up with extra lines in the report with the message property in the upper left hand corner of each table. I debugged the PSM1 file and found that the group header is generated as an HTML fragment followed by another line which tries to use a series "-replace" operators to remove non-header related information. When those "replaces" don't find a match, you end up with junk in your header. Specifically, I believe in my case this particular -Replace statement wasn't matching for whatever reason: -replace ".+?" I modified the following lines in the .psm1 file (Lines 958 and 959): $GroupHeader = $ArrayOfObjects | ConvertTo-Html -Fragment $GroupHeader = $GroupHeader -replace '', "" -replace '', "" -replace '', "" -replace '

', "" -replace '
', "" -replace ".+?" -replace "", "" Modified: ForEach ($Item in $Groupings) {$GroupHeader = $GroupHeader + "$Item"} $GroupHeader="$GroupHeader" This corrected my issue. Perhaps this change will be more robust since it doesn't rely upon string matches, but generates the header information from the list of distinct list of Groupings. Thank you, Brian

Henry-Jones commented 4 years ago

I stumbled over the same problem. For me the "junk" collected if the last column was empty, so I replaced quantor ".+?" with ".*" which solved the problem as well.