Custom CSV Rendering Extension question
Hi,
I'm attempting to implement a custom CSV renderer in SSRS 2008. It works successfully for some RDLs, but not others. The issue seems to be the my traversal of the Tablix heirarchy. Here is the core Tablix code:
else if (type.Equals(typeof(Tablix)))
{
Tablix tl = (Tablix)item;
TablixMemberCollection tlchmc = tl.ColumnHierarchy.MemberCollection;
for (int i = 0; i < tlchmc.Count; i++)
{
RenderTablixMember(stream, tl, tlchmc[i], false);
}
TablixMemberCollection tlrhmc = tl.RowHierarchy.MemberCollection;
for (int i = 0; i < tlrhmc.Count; i++)
{
RenderTablixMember(stream, tl, tlrhmc[i], true);
}
}
protected void RenderTablixMember(CsvStreamWriter stream, Tablix tablix, TablixMember member, bool processRows)
{
if (member.IsStatic)
{
if (member.Instance != null)
{
if (processRows == true)
{
TablixRow tlr = tablix.Body.RowCollection[member.MemberCellIndex];
for (int j = 0; j < tlr.Count; j++)
{
TablixCell tlc = tlr[j];
if (tlc != null)
RenderReportItem(stream, tlc.CellContents.ReportItem);
}
stream.WriteLine();
}
else
{
TablixColumn tlcm = tablix.Body.ColumnCollection[member.MemberCellIndex];
if (tlcm != null)
{
System.Diagnostics.Debug.WriteLine("TablixColumn is not NULL!");
}
}
}
if (member.Children != null)
{
foreach (TablixMember tm in member.Children)
{
RenderTablixMember(stream, tablix, tm, processRows);
}
}
}
else if (processRows == true)
{
TablixDynamicMemberInstance tldmi = (TablixDynamicMemberInstance)member.Instance;
tldmi.ResetContext();
while (tldmi.MoveNext())
{
TablixRow tlr = tablix.Body.RowCollection[member.MemberCellIndex];
if (tlr != null)
{
for (int j = 0; j < tlr.Count; j++)
{
TablixCell tlc = tlr[j];
if (tlc != null)
RenderReportItem(stream, tlc.CellContents.ReportItem);
else
System.Diagnostics.Debug.WriteLine("TablixCell (row) is NULL!");
}
stream.WriteLine();
}
}
}
else if (processRows == false)
{
TablixDynamicMemberInstance tldmi = (TablixDynamicMemberInstance)member.Instance;
tldmi.ResetContext();
while (tldmi.MoveNext())
{
TablixColumn tlcm = tablix.Body.ColumnCollection[member.MemberCellIndex];
if (tlcm != null)
{
System.Diagnostics.Debug.WriteLine("TablixColumn is not NULL!");
}
}
}
}
}
I've seen a number of posts which state that the row and column heirarchies are traversed in the same manner. I can't see how to do this since TablixColumn does not contain a Count member. Can anyone review my code and let me know where I'm going wrong please?
Thanks!
August 8th, 2011 1:29pm
I figured it out. Since the the (dynamic) tablix member structure is heirarchical, it is necessary to check for any chilren inside the while MoveNext loops. I'm still not sure if static tablix members can have children or not but will leave this check in
place just in case.
Free Windows Admin Tool Kit Click here and download it now
August 8th, 2011 5:40pm
Hi Jamie..
did you consider the case when your Tablix has data in Matrix form.
i am not getting ColumnCollection in that case. instead Corner object is coming in Tablix object but i don't know how to use Corner
object :(
can you please throw some light on it.
Thanks,
Sachin
August 9th, 2011 4:53am
JamieR007,
Thank you for your question.
I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated.
Thank you for your understanding and support.
Thanks,
Eileen
Free Windows Admin Tool Kit Click here and download it now
August 12th, 2011 12:22am
Jamie,
This was escalated up to me yesterday but from your last post it appears that you have resolved your own issue. If this is the case please mark the post as answered.
ThanksTerrell An -MSFT
September 2nd, 2011 9:16am
Hi in dinamic members you need call the childrens
.... else if (processRows ==
true)
{
TablixDynamicMemberInstance tldmi = (TablixDynamicMemberInstance)member.Instance;
tldmi.ResetContext();
while (tldmi.MoveNext())
{
TablixRow tlr = tablix.Body.RowCollection[member.MemberCellIndex];
if (tlr !=
null)
{
for (int j = 0; j < tlr.Count; j++)
{
TablixCell tlc = tlr[j];
if (tlc != null)
RenderReportItem(stream, tlc.CellContents.ReportItem);
else
System.Diagnostics.Debug.WriteLine("TablixCell (row) is NULL!");
}
if (member.Children !=
null)
{
foreach (TablixMember tm
in member.Children)
{
RenderTablixMember(stream, tablix, tm, processRows);
}
}
stream.WriteLine();
}
}
Free Windows Admin Tool Kit Click here and download it now
May 26th, 2012 2:23pm