locked
SSRS removes spaces and line breaks from single field report RRS feed

  • Question

  •  

    I am storing formatted data (including spaces and line breaks) in a single field in a table.

    When I run a report on that field, the preview of the report is automatically removing all the extra spaces and line breaks, making the report unreadable.

    When exporting the report to PDF or printing it, it shows the line breaks and spaces as expected.

     

    Does anyone know how to make the report preview show the spaces and line breaks?

     

    Wednesday, January 2, 2008 6:36 PM

Answers

  • That is interesting. I am able to use carriage returns with my data in a table that is rendered in HTML. I am using a NTEXT field in my SQL table and inserting data that has carriage returns.

     

    In the rendering code, there is an explicit check for "\r\n" which is turned into html "<br>". If by chance your data is only broken with "\r" or "\n", the "<br>" is not inserted. For example, Word only inserts a "\r" when it creates the document and will not render a break with the HTML renderer.

    Monday, January 7, 2008 5:35 PM

All replies

  • Hi Francis,

     

    There are slight differences in how each Reporting Services rendering extension handle in line formatting. For HTML, tab is treated as a space and extra spaces are removed. Carriage returns are preserved. PDF and the image formats do not remove the spaces and will preserve tabs and carriage returns. XML does not by default support tab, carriage returns or extra spaces. But does have UseFormattedValues Device Info that allows for outputting textbox formatting.

     

    In RS2008, we are working on a rich textbox that will help make formatting consistent across all rendering extensions. Here is one forum link talking about it. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1827171&SiteID=1

     

     

    Wednesday, January 2, 2008 11:06 PM
  • Brad,

    I am rendering the report in HTML, but carriage returns are not preserved for me. I found a workaround for the spaces, but without the carriage returns the report is still unusable. Is there a setting I am not aware of?

     

     

     

    Thursday, January 3, 2008 6:38 PM
  • That is interesting. I am able to use carriage returns with my data in a table that is rendered in HTML. I am using a NTEXT field in my SQL table and inserting data that has carriage returns.

     

    In the rendering code, there is an explicit check for "\r\n" which is turned into html "<br>". If by chance your data is only broken with "\r" or "\n", the "<br>" is not inserted. For example, Word only inserts a "\r" when it creates the document and will not render a break with the HTML renderer.

    Monday, January 7, 2008 5:35 PM
  •  

    What is your workaround for the spaces. I could really use some help with keeping the spacing in my reports. Thanks in advance for any help.

     

    Frank

    Thursday, April 17, 2008 7:14 PM
  • I ended up having to do a solution outside of SSRS because I couldn't get past the line break issue, so I don't have any code to share with you.

    For the spaces I believe I used the HTMLDecode /HTMLEncode function (http://msdn2.microsoft.com/en-us/library/system.web.httpserverutility.htmldecode.aspx ). It converted the spaces to a value that preserved the space in the preview.

     

    Thursday, April 17, 2008 8:16 PM
  • Is there a way to make this work when rendering text in HTML format? I want to preserve carriage returns, tabs, etc.

     

    Wednesday, July 9, 2008 4:39 PM