In the crystal reports, fields do not clip if they are over the specified length but rather continue to write over and you end-up seeing many fields on top of each other. But this behaviour is true only when you run the application. If you check the report
preview during design time, it is shown correctly.
I had a problem with fields in Crystal Reports X where data driven textboxes would not grow to the right to accommodate the text length. It would grow in Height and overlap a textbox that was placed directly below it. It's important to note that the textboxes
were both in the same section of the report (Details). I solved this by splitting the section into Details a and Details b. The sections would grow as the textbox grew and move the section below down, hence preventing the overlap.
If I have a seperate section, then there will be another line below it. This is not what I want. I want a single line to show all the details. The width I set is good enough to show enough details.
One workround I found is to set the cangrow attribute to true and number of lines attribute to 1 (of the fieldobject). But this also produces slightly ugly report if the content cannot fit to the allocated width, the field's vertical alignment does not match
with the rest of the items and becomes higher.
You have a control, I'm assuming a data driven textbox, that when it gets too large for the text box, you want to clip...or truncate? It shows correctly in the Designer but when publishing, it's displaying wacky. Text overlapping? I'm not clear on what
behavior you are witnessing here. Is there more than one control that is overlapping? Is it multiple records overlapping? Is the text wrapping withing the textbox and it doesn't grow so you either see the tops of the next line or it repeats overtop itselff?
If you are looking to simply truncate text to fit in the textbox, I would suggest creating a function to trim the datafield to a set number of characters that match your textbox width. You could even create a hidden section that contained the entire text
in a larger area so if they expanded the section they could read the entire record.
I've used Crystal Reports since 6.0 and I understand how buggy it can be. What version are you using? Is there any way you can provide more information or a sample? I may be able help if I can duplicate your issue.
Also, what are you displaying the report in? Is it the CrystalReportsViewer? ActiveX component? Java Component? Crystal Reports Server? They all can have their own little quirks.
Ok, to make things a bit clearer, I have a report file (.rpt) and I have a CrystalReportViewer control, that shows the .rpt file. And my problems are with the CrystalReportViewer. If I export the report to pdf, the pdf file shows how it is ment to display
but when you view the report on the web page, CrystalReportViewer stuffs things up.
I am using Visual Studio 2005 Professional and there is no versioning mentioned for the Crystal Reports. It just says Crystal Reports for Visual Studio 2005. I believe it is almost the same version as X but not sure.
I have side by side text fields (IFieldObject to be exact) in the section details section on a single line. The data to be displayed in some of these fields are longer than the width of these fileds. What I am expecting is the data to be clipped if the text
is longer than the width of the textboxes. But instead, the entire text gets written, regarless of its length, over the next text boxes (IFieldObjects). One solution as you suggested is to trim the underlying text programmatically. But this solution also has
some defficiencies if the font is not monospaced plus, to amount of work required to figure-out how many characters for each textbox width for various font sizes and properties (like bold, italic, etc) and the additional potential work in the future if you
want to resize the text boxes.
The CanGrow workaround I mentioned before also has defficiencies since it does not utilise the full length of the textbox if the underlying text has spaces as it tries to write the text by not dividing the words. Also, its vertical alignment changes as well.
This workaround is more feasible If I can set the vertial alignments to top as you suggested but there is no property for vertial aligment. The workaround to the workaround is to set the heights of the textboxes to a very small size but If you do that, the
pdf export gets screwed!
I am sorry not providing any samples as the forum does not allow attachments but you can experiment by using CrystalReportViewer and long texts as underlying data for relatively narrow textboxes.
Thanks for the info. I'm trying to duplicate your results right now. If you prefer, you can contact me directly at
ttillotson@ttsos.com so we can exchange examples or screenshots. Then, when we have a solution, we can post it back to the blog to close it out.
You are correct on how the versions of Crystal Reports are distributed. The Crystal Reports for Visual Studio 2005 is its own version. It is supported by Microsoft rather than BusinessObjects. I use the CrystalReportViewer 10.2 with the VS2005 version but
haven't seen this issue. I've also used Crystal Reports XI with the same control. (I know..., "Works on my machine." stupid comment) This just indicates that I haven't captured the exact configuration you have in order to duplicate the bug. I'm using a sample
VS2005 report.
What is your datasource? SQL Server? version? What is the database field type?
Can you send the full control tag on your aspx page? Example:
Have you tried the "Lock position and size" property in the Common tab for the field format properties? (Just a wild try). You can format the vertical alignment using a cascading style sheet and placing the CSS Class Name into the same Common tab.
So far as you have mentioned, it works fine in the designer. More to follow.
Here's another quick thing you can try. Try setting the configuration of the report from the code side instead of in the Report Designer. I'm getting a hunch that the format of the object may be getting overridden when you create your iFieldObject. Honestly,
I haven't used the IFieldObject through code before so I may be out of my league on your question.
This is the code behind a basic aspx web form. Hopefully it may offer a little insight that may make more sense to you than it does to me right now.
Partial Class TestReport
Inherits System.Web.UI.Page
Private crReport
As ReportDocument
Private crPath
As String
Private
Sub ConfigureCrystalReports()
crPath =
"reports/CanGrowReport.rpt"
Dim reportpath
As String = Server.MapPath(crPath)
Dim ReportType
As String =
""
Dim ReportTypeCriteria
As String =
"CrystalDecisions.CrystalReports.Engine.FieldObject"
Try
crReport = New ReportDocument()
crReport.Load(reportpath)
crvDocumentViewer.ReportSource = crReport
Dim fo As CrystalDecisions.CrystalReports.Engine.FieldObject =
Nothing
For i
As Integer = 0
To crReport.ReportDefinition.ReportObjects.Count
If ReportType.Equals(ReportTypeCriteria)
Then
fo = DirectCast(crReport.ReportDefinition.ReportObjects(i), CrystalDecisions.CrystalReports.Engine.FieldObject)
fo.ObjectFormat.EnableCanGrow =
True
End If
Next
Catch ex
As Exception
End Try
End Sub
Protected Sub Page_Init(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles Me.Init
ConfigureCrystalReports()
End Sub
Private
Sub CodeBag()
'public static void EnableReportFieldsMultiline(CrystalDecisions.CrystalReports.Engine.ReportDocument rep)
'{
' CrystalDecisions.CrystalReports.Engine.FieldObject fo;
' for (int i = 0; i < rep.ReportDefinition.ReportObjects.Count; i++)
' {
' if (rep.ReportDefinition.ReportObjects[i] is CrystalDecisions.CrystalReports.Engine.FieldObject)
' {
' fo = (CrystalDecisions.CrystalReports.Engine.FieldObject)rep.ReportDefinition.ReportObjects[i];
' fo.ObjectFormat.EnableCanGrow = true;
' }
' }
'}
I did something very similar to your code for programmatically changing the property. It changes the propery (cangrow) fine but as I said before, if the line is more than one, its vertical alignment also changes slightly and do not perfectly line-up.
I created a new project for this bug only. It is using the MS SQL 2005 sample database AdventureWorks and just pulled-out some data to show the problem plus the screenshot and the pdf version of the report
and sent it to your email address you give above.
Were you able to resolve this issue? I' m having a similar problem.I have too many columns.I tried fit them in using Landscape mode but fields run over each other. Please advise.
jsdude99
Member
17 Points
117 Posts
Crystal report fields spill-over - do not clip
May 12, 2008 07:13 AM|LINK
In the crystal reports, fields do not clip if they are over the specified length but rather continue to write over and you end-up seeing many fields on top of each other. But this behaviour is true only when you run the application. If you check the report preview during design time, it is shown correctly.
tsttntice
Member
16 Points
8 Posts
Re: Crystal report fields spill-over - do not clip
Jun 12, 2008 05:02 PM|LINK
I had a problem with fields in Crystal Reports X where data driven textboxes would not grow to the right to accommodate the text length. It would grow in Height and overlap a textbox that was placed directly below it. It's important to note that the textboxes were both in the same section of the report (Details). I solved this by splitting the section into Details a and Details b. The sections would grow as the textbox grew and move the section below down, hence preventing the overlap.
jsdude99
Member
17 Points
117 Posts
Re: Crystal report fields spill-over - do not clip
Jun 12, 2008 11:13 PM|LINK
If I have a seperate section, then there will be another line below it. This is not what I want. I want a single line to show all the details. The width I set is good enough to show enough details.
One workround I found is to set the cangrow attribute to true and number of lines attribute to 1 (of the fieldobject). But this also produces slightly ugly report if the content cannot fit to the allocated width, the field's vertical alignment does not match with the rest of the items and becomes higher.
tsttntice
Member
16 Points
8 Posts
Re: Crystal report fields spill-over - do not clip
Jun 13, 2008 12:29 AM|LINK
Ok, Let me see if I understand what you want.
You have a control, I'm assuming a data driven textbox, that when it gets too large for the text box, you want to clip...or truncate? It shows correctly in the Designer but when publishing, it's displaying wacky. Text overlapping? I'm not clear on what behavior you are witnessing here. Is there more than one control that is overlapping? Is it multiple records overlapping? Is the text wrapping withing the textbox and it doesn't grow so you either see the tops of the next line or it repeats overtop itselff?
If you are looking to simply truncate text to fit in the textbox, I would suggest creating a function to trim the datafield to a set number of characters that match your textbox width. You could even create a hidden section that contained the entire text in a larger area so if they expanded the section they could read the entire record.
I've used Crystal Reports since 6.0 and I understand how buggy it can be. What version are you using? Is there any way you can provide more information or a sample? I may be able help if I can duplicate your issue.
Also, what are you displaying the report in? Is it the CrystalReportsViewer? ActiveX component? Java Component? Crystal Reports Server? They all can have their own little quirks.
tsttntice
Member
16 Points
8 Posts
Re: Crystal report fields spill-over - do not clip
Jun 13, 2008 12:38 AM|LINK
I should also mention that you can set sections to "overlay". This way two separate sections can look like one. It is usually used for graphics.
Also, you can align all your textboxes to vertical align top so when your field grows, all your textboxes stay aligned.
jsdude99
Member
17 Points
117 Posts
Re: Crystal report fields spill-over - do not clip
Jun 16, 2008 12:31 AM|LINK
tsttntice,
Ok, to make things a bit clearer, I have a report file (.rpt) and I have a CrystalReportViewer control, that shows the .rpt file. And my problems are with the CrystalReportViewer. If I export the report to pdf, the pdf file shows how it is ment to display but when you view the report on the web page, CrystalReportViewer stuffs things up.
I am using Visual Studio 2005 Professional and there is no versioning mentioned for the Crystal Reports. It just says Crystal Reports for Visual Studio 2005. I believe it is almost the same version as X but not sure.
I have side by side text fields (IFieldObject to be exact) in the section details section on a single line. The data to be displayed in some of these fields are longer than the width of these fileds. What I am expecting is the data to be clipped if the text is longer than the width of the textboxes. But instead, the entire text gets written, regarless of its length, over the next text boxes (IFieldObjects). One solution as you suggested is to trim the underlying text programmatically. But this solution also has some defficiencies if the font is not monospaced plus, to amount of work required to figure-out how many characters for each textbox width for various font sizes and properties (like bold, italic, etc) and the additional potential work in the future if you want to resize the text boxes.
The CanGrow workaround I mentioned before also has defficiencies since it does not utilise the full length of the textbox if the underlying text has spaces as it tries to write the text by not dividing the words. Also, its vertical alignment changes as well. This workaround is more feasible If I can set the vertial alignments to top as you suggested but there is no property for vertial aligment. The workaround to the workaround is to set the heights of the textboxes to a very small size but If you do that, the pdf export gets screwed!
I am sorry not providing any samples as the forum does not allow attachments but you can experiment by using CrystalReportViewer and long texts as underlying data for relatively narrow textboxes.
tsttntice
Member
16 Points
8 Posts
Re: Crystal report fields spill-over - do not clip
Jun 16, 2008 12:58 PM|LINK
Thanks for the info. I'm trying to duplicate your results right now. If you prefer, you can contact me directly at ttillotson@ttsos.com so we can exchange examples or screenshots. Then, when we have a solution, we can post it back to the blog to close it out.
You are correct on how the versions of Crystal Reports are distributed. The Crystal Reports for Visual Studio 2005 is its own version. It is supported by Microsoft rather than BusinessObjects. I use the CrystalReportViewer 10.2 with the VS2005 version but haven't seen this issue. I've also used Crystal Reports XI with the same control. (I know..., "Works on my machine." stupid comment) This just indicates that I haven't captured the exact configuration you have in order to duplicate the bug. I'm using a sample VS2005 report.
What is your datasource? SQL Server? version? What is the database field type?
Can you send the full control tag on your aspx page? Example:<
CR:CrystalReportViewer ID="crvDocumentViewer" runat="server" ..........Also the registry tag:
<%
@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %>Have you tried the "Lock position and size" property in the Common tab for the field format properties? (Just a wild try). You can format the vertical alignment using a cascading style sheet and placing the CSS Class Name into the same Common tab.
So far as you have mentioned, it works fine in the designer. More to follow.
tsttntice
Member
16 Points
8 Posts
Re: Crystal report fields spill-over - do not clip
Jun 16, 2008 04:21 PM|LINK
Here's another quick thing you can try. Try setting the configuration of the report from the code side instead of in the Report Designer. I'm getting a hunch that the format of the object may be getting overridden when you create your iFieldObject. Honestly, I haven't used the IFieldObject through code before so I may be out of my league on your question.
This is the code behind a basic aspx web form. Hopefully it may offer a little insight that may make more sense to you than it does to me right now.
Option Strict On Option Explicit OnImports
CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.SharedImports
SSTART Imports System.Collections
Partial Class TestReport Inherits System.Web.UI.Page Private crReport As ReportDocument Private crPath As String Private Sub ConfigureCrystalReports()crPath =
"reports/CanGrowReport.rpt" Dim reportpath As String = Server.MapPath(crPath) Dim ReportType As String = "" Dim ReportTypeCriteria As String = "CrystalDecisions.CrystalReports.Engine.FieldObject" Try crReport = New ReportDocument()crReport.Load(reportpath)
crvDocumentViewer.ReportSource = crReport
Dim fo As CrystalDecisions.CrystalReports.Engine.FieldObject = Nothing For i As Integer = 0 To crReport.ReportDefinition.ReportObjects.CountReportType = crReport.ReportDefinition.ReportObjects(i).GetType.ToString
If ReportType.Equals(ReportTypeCriteria) Then fo = DirectCast(crReport.ReportDefinition.ReportObjects(i), CrystalDecisions.CrystalReports.Engine.FieldObject)fo.ObjectFormat.EnableCanGrow =
True End If Next Catch ex As Exception End Try End Sub Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.InitConfigureCrystalReports()
End Sub Private Sub CodeBag() 'public static void EnableReportFieldsMultiline(CrystalDecisions.CrystalReports.Engine.ReportDocument rep) '{ ' CrystalDecisions.CrystalReports.Engine.FieldObject fo; ' for (int i = 0; i < rep.ReportDefinition.ReportObjects.Count; i++) ' { ' if (rep.ReportDefinition.ReportObjects[i] is CrystalDecisions.CrystalReports.Engine.FieldObject) ' { ' fo = (CrystalDecisions.CrystalReports.Engine.FieldObject)rep.ReportDefinition.ReportObjects[i]; ' fo.ObjectFormat.EnableCanGrow = true; ' } ' } '}
End SubEnd
Classjsdude99
Member
17 Points
117 Posts
Re: Crystal report fields spill-over - do not clip
Jun 16, 2008 11:32 PM|LINK
I did something very similar to your code for programmatically changing the property. It changes the propery (cangrow) fine but as I said before, if the line is more than one, its vertical alignment also changes slightly and do not perfectly line-up.
I created a new project for this bug only. It is using the MS SQL 2005 sample database AdventureWorks and just pulled-out some data to show the problem plus the screenshot and the pdf version of the report and sent it to your email address you give above.
rkodur
Member
2 Points
1 Post
Re: Crystal report fields spill-over - do not clip
Jul 03, 2008 02:30 PM|LINK
Were you able to resolve this issue? I' m having a similar problem.I have too many columns.I tried fit them in using Landscape mode but fields run over each other. Please advise.
Thanks!!