Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 RS Loses Spaces at Beginning Of Field

Author  Topic 

eric_ht
Starting Member

37 Posts

Posted - 2009-09-21 : 15:16:04
I have a report that gets information from a stored procedure. The stored procedure Indents the text in the first column on certain rows to make them more readable.

When I look at the report in preview mode in Visual Studio the column looks correct. When I deploy the report to the Reporting Server and run the report the spaces at the beginning of the field are lost and everything is left justified. I can export to Excel and the spacing is retained. I export to PDF and the spaces are also removed.

How can I make RS keep my formatting?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-09-21 : 15:26:19
I don't have an answer as to how to fix RS, but I wanted to comment that the stored procedure should never do any formatting of data. Formatting of data needs to be done at the application layer, which in your case is RS. I'd suggest removing the formatting from the stored procedure and then having RS do the indentation. You may perhaps fix your issue by doing it this way.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

eric_ht
Starting Member

37 Posts

Posted - 2009-09-21 : 20:36:59
Thanks Tara.

At first I didn't 100% agree with you assessment of never formatting the data on the database side. I guess partly from being more of a database person and ignorant in the ways of Reporting Services. And it doesn't help that I would get the same results when formatting the field on the RS side. (I was still trying to concat the spaces onto the field in RS) I still don't understand why the viewer shows different results than the deployed report. Don't they both use the RS engine?

Anyway, so to solve the problem I returned a flag from the Stored Proc to indicated if the field needed to be indented or not and used that in the Padding expression to change the left padding. Now it works in the viewer and when exporting to PDF.

OK I still may not 100% agree but you were right on in this situation.

Thanks again
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-09-21 : 22:26:25
You might not agree, but what I have described is the recommended and preferred approach. T-SQL is not designed for presentation issues.

Glad to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

Dralin
Starting Member

1 Post

Posted - 2009-11-20 : 12:12:07
Sorry to resurrect this thread, but I think I may have some helpful input. I am not sure if this is what you are trying to do, but to indent only the first row, you can use the "hanging indent" property of the textbox. A positive hanging indent will indent the first row while a negative hanging indent will indent subsequent rows within the textbox. Using your flag, you could create the expression in the hanging indent property instead of the padding property. This would be useful if you want to indent only part of the text in a single textbox and not the entire record for that textbox.
Go to Top of Page
   

- Advertisement -