Archive

Archive for June, 2013

Dynamic grouping in crystal report from code

Here CRRep is a crystal reort object

Hide Section

For X = 1 To CRRep.Sections.Count
If CRRep.Sections.Item(CInt(X)).Name = “SectionName” Then
CRRep.Sections.Item(CInt(X)).Suppress = True
End If
Next

Change Sorting

Set CRField = CRRep.Database.Tables(SortTable).Fields.GetItemByName(CStr(“SortByColumn”))
CRRep.RecordSortFields.Item(1).Field = CRField

Change Grouping

Dim GroupTable
Dim GroupDBFieldName
Set CRField = CRRep.Database.Tables(GroupTable).Fields.GetItemByName(CStr(GroupDBFieldName))
CRRep.Areas.Item(“GH1”).GroupConditionField = CRField

Paassing parameter in sub report

For Each Section In CRRep.Sections
For Each RepObject In Section.ReportObjects
If RepObject.Kind = 5 Then
Set SubRep = RepObject.OpenSubReport
‘ Replaceable Parameters in Sub Reports
For Each ParamDef In SubRep.ParameterFields
”’ If ParamDef.ParameterFieldName = “Date” Then
”’ ParamDef.SetCurrentValue CDate(“date”)
”’ End If
Next
Set SubRep = Nothing
End If
Next
Next

Categories: Other

Remove attributes from xml

public void IntermediateProcess(string xmlFilePath)
{

XmlDocument xmlDoc = new XmlDocument();
FileInfo fileInfo = new FileInfo(_xmlFilePath);
if (fileInfo.Exists)
{
xmlDoc.Load(_xmlFilePath);

XmlNodeList listFormField = xmlDoc.GetElementsByTagName(“TagName”);
foreach (XmlNode node in listFormField)
{
node.Attributes.RemoveNamedItem(“attributename”);
}
xmlDoc.Save(_xmlFilePath);
}
}

Categories: C#