When you are pulling a huge text field data from the database, Active Reports breaks the text into multiple rows. Sorting the excel sheet columns will be a problem with the way active report generates the Exel report. Below is the code to change the default behavior of the excel format Active Report. All you will need to do is explicitly set wordwrap on the controls to false. Here, I am looping to find all the controls and setting the word wrap on each control to false.
// To fix excel reports from displaying single cell data in multiple rows
if (IsXls == true)
{
Section Hsec = this.Sections["pageHeader"];
for (int i = 0; i < Hsec.Controls.Count; i++)
{
if ((Hsec.Controls[i].GetType()).ToString() == "DataDynamics.ActiveReports.Label")
{
((Label)(Hsec.Controls[i])).WordWrap = false;
}
}
Section sec = this.Sections["detail"];
for (int i = 0; i < sec.Controls.Count; i++)
{
if ((sec.Controls[i].GetType()).ToString() == "DataDynamics.ActiveReports.TextBox")
{
((TextBox)(sec.Controls[i])).WordWrap = false;
}
}
}
2 comments:
Interesting... I'll try that.
You can get the controls of a specific type with:
controls.OfType<TextBox>()
with linq introduced in .net 3.5
Post a Comment