Welcome to the Axosoft Community, Sign in | Register | Help
in Search

Any C# sample code for stripping HTML from custom reports?

Last post 04-06-2006, 11:29 AM by Rob Bowman. 6 replies.
Sort Posts: Previous Next
  •  10-12-2005, 12:16 PM 4653

    Any C# sample code for stripping HTML from custom reports?

    Has anyone written C# code for the custom reports to strip out HTML from the Description and Notes fields?

    Translating the HTML would even be better if you have any of that code.

    Thanks.

  •  10-19-2005, 4:55 AM 4654 in reply to 4653

    RE: Any C# sample code for stripping HTML from custom reports?

    I half-way wrote some C# code to replace a few HTML tags, the strip the rest, so my custom reports would print at least somewhat OK.  If anyone has improvements or updates to this code, please post them.  Thanks.

    public void Detail_Format()
    {
    string strReturn;
    int si, se;

    strReturn = ((TextBox) rpt.Sections["Detail"].Controls["txtDescription"]).Text;

    if(strReturn.Length > 2)
     {
     // Replace some common HTML Tags
     strReturn = strReturn.Replace("</P>", "\n");
     strReturn = strReturn.Replace("<BR>", "\n");
     strReturn = strReturn.Replace("<LI>", "\t* ");
     strReturn = strReturn.Replace("</TD>", "\t");
     strReturn = strReturn.Replace("</TR>", "\n");
     strReturn = strReturn.Replace("&nbsp;", " ");


     // Erase any remaining HTML tags
     si = strReturn.IndexOf("<");
     se = strReturn.IndexOf(">");

     while(si>=0 && se>=0 && si<se)
      {
      strReturn = strReturn.Substring(0, si) + strReturn.Substring(se+1, strReturn.Length-se-1);
      si = strReturn.IndexOf("<");
      se = strReturn.IndexOf(">");
      }

     strReturn = strReturn.Replace("&lt;", "<");
     strReturn = strReturn.Replace("&gt;", ">");

     ((TextBox) rpt.Sections["Detail"].Controls["txtDescription"]).Text = strReturn;
     }
    }

  •  10-24-2005, 9:14 AM 4655 in reply to 4653

    RE: Any C# sample code for stripping HTML from custom reports?
    We have a method in OnTime which converts HTML to Text and we will try to make this available in custom reports (so you can just call our method from the script).
    Dragan Marceta
    www.Axosoft.com
  •  10-26-2005, 4:10 PM 4656 in reply to 4653

    RE: Any C# sample code for stripping HTML from custom reports?

    For release we are making the Rich Text Box control from Active Reports available to end users (as well as us using it in our Details reports).  Using this control you will be able to print HTML content.


    Dragan Marceta
    www.Axosoft.com
  •  04-03-2006, 9:55 AM 4657 in reply to 4653

    RE: Any C# sample code for stripping HTML from custom reports?

    I try to use Rich Text Box control to print HTML content but still cant get rif of the HTML tags from the description and notes fields. Could you explain more about how to use Rich Text Box control?

    Thank you

  •  04-05-2006, 7:46 AM 4658 in reply to 4653

    RE: Any C# sample code for stripping HTML from custom reports?

    See this thread: http://forums.axosoft.com/shwmessage.aspx?forumid=9&messageid=5645#bm5646

    Also, the Windows User's Guide for 6.1 has been updated with better documentation for custom reporting.


    Dragan Marceta
    www.Axosoft.com
  •  04-06-2006, 11:29 AM 4659 in reply to 4653

    RE: Any C# sample code for stripping HTML from custom reports?
    The C# scripted linked in one of the previous posts works but it is very slow. When trying to render anything more than a few records with large notes fields my PC hangs. It's not a problem with the PC as I've tried several high spec machines. Anyone know an efficient method of displaying formatted HTML in the reports?
View as RSS news feed in XML

© 2002 - 2007, Axosoft, LLC. All Rights Reserved. | Privacy
Bug Tracking | Defect Tracking Videos | Help Desk Software