Add text box at specific location in report base on value - vba

I'm working on a cut list generator but I'm having difficulty on the final report. I'd like to display a rectangle that represents the factory length piece with lines indicating cut points. In each segment I'd like to have the length of the piece shown. Using Report.line I've created the rectangles needed but I'm not sure how to get text in each box. Here is a sample output so far As an example I want the three rectangles for Piece #1 to have 48" in them, probably all the way to the left. Any suggestions? I thought createReportControl might work but I'm not sure that is the correct approach. I'm also thinking about one text box with a monospace font so I can scale the input across the entire width. Any suggestions are appreciated.
Thanks,
Dave
I played around with the monospace font idea. It isn't as pretty as I would like but I'm getting closer.

The issue is that I cannot keep the text in the same spot in each box. There is one line lower on the page that pushes the number almost out the right side of the box.
Sample Output
This code is functional but I'm looking at the cosmetics. I'm inserting spaces between my values using the following function:
Private Function InsertSpaces(CutLen, PieceLen) As String
MaxChar = 50 ' 6 inch 14pt Courier text box
cutchar = Int(CutLen / PieceLen * MaxChar)
Cutcharcount = Len(Str(CutLen))
cutchar = cutchar - Cutcharcount + 1
For i = 1 To cutchar
InsertSpaces = InsertSpaces + " "
Next
End Function
I'm just trying to clean it up. CreateReportControl was giving me a error because I wasn't in design mode. I'm guessing that is because it ran as part of OnFormat of the Detail section.

Related

Should this boxes for my custom Object Detector be smaller?

So Im trying to make a Object Detector for this companys forms, and we have labelled the images as shown in the example image I uploaded, my question is: Should We make more accurate boxes or is OK as they are, since the written part that we are trying to detect could be bigger.
So, what im asking is: In the example image, the "Descripcion" part or Description, has just 2 lines of text, but it could be more, should we make the box to just select the Description title + the 2 lines or so we stick to what we are doing now title + the 2 lines + all blank space that could have been filled with lines
It depends on what you really want to do with the detected boxes. What are the next steps, can the next step e.g. extracting the text handle all the free space, or would it be better to just the the part where it is actually written.
Besides that right now in your example I find that most boxes are too big. The form is more or less already splitted in boxes and it could be better to make the boxes smaller and more accurate e.g.the box around IMPORTE and some amount in €. I would label this closer. So the box only contains the information you actually want and nothing else.
But as I said it really depends on the next step the boxes should be used for.

Getting display text as ###### for some of the cell in excel after writing from Vb.net code

I am writting to an excel file from my vb code. The code goes as below
xlsheet3 = xlBook.Sheets.Add(After:=xlSheet)
With xlsheet3
.Columns(5).NumberFormat = "#"
.Cells(j + 1, 5) = someStringValue 'Here "j" is a row counter and this line is in a "for loop"
end with
After writing to excel, most of the cells in excel are correct. But some of the cell's text comes as ####### however if I click on the cell, formula bar shows the correct result. I have tried giving single code before adding the text still that did not help.
Please help me in resolving this.
Thank you
There is not any issue with your code. You need to increase the width of the column or have to use word wrap. In excel if your value is not fully visible it shows it is "######".
If widening and wrapping text doesn't work and the format is set to text which allows display of only 255 characters, try changing the format to general.
This just indicates that the cell is too small for showing the result: make it wider.
See https://superuser.com/questions/65556/excel-displays-for-long-text-whats-wrong for some common reasons why Excel displays "######" in cells.
Either the cell is too narrow to display the contents or the contents are over 256 characters.
Check what you're writing to the cell. If it's not too long then all you need to do is resize the column to fit the new contents.
This is simply what Excel does when the data in a column is too wide to be displayed in the current column width. Make the column slightly wider and you will see all your data.
To autosize the column so it is wide enough to display all its data, double click the column divider at the right edge of the column, in the header bar.

Crystal Reports Cutting Off Text in PDF

I found this post on Crystal Reports Cutting Off Text in PDF, but it didn't solve my problem.
I have a Crystal Report that contains a field within a text object (to control line spacing) and has "can grow" selected. When I export the Crystal Report to a PDF there are instances when the text is cut off.
In this example the text is being cut off on the right side, but in some cases, when the text consists of many lines, the bottom part of the last line will be partially cut off.
I am using Crystal Reports that is bundled with Visual Studio 2008. The text area has "can grow" checked, the font is set to Helvetica LT Condensed, bold 14, and the line spacing is set to 0.75 times normal.
Anyone have any thoughts on how can I fix this?
I have run into this as well - Crystal seems a little confused about where the text box borders are. I suggest adding a small right indent to the text box (right click on the text box, select 'Format Object', select the 'Paragraph' tab, and enter small numbers (maybe .2 or so) into the Right text box. This should help with the right margin.
As for the bottom cut-off, there is no margin that you can add. Can you add a line break to the end of your text as it comes from the db? Or, you could try a formula field to add the line break:
{table_name.field_name} + chr(13) + chr(10)
I think I've found out the problem. The bounding subreport width was smaller than the width of the field object. Adjusting it's width fixed the truncation occurring on the right-hand side.
On a side note, text being truncated on the bottom seems to be a result of adjusting the line-spacing too small. if you set the line spacing as a multiple of the original text point size and make it too small, the bottom part of the line is truncated. I changed this to "exact" and entered a specific point size (e.g line spacing of 18 pt. for my 16 pt. text) and this seemed to solve the problem. If the line spacing is too small it seems that Crystal masks off the bottom part of the text.
Right click on the text field
Select Common Tab
In the Horizontal Alignment section I changed it to "Justified".
This adjusted the text to span properly and not cut off prematurely when using Can Grow.
I tried this and it solved this issue.
Try to do following :
Text Object > Right Click > Format Text > Border Tab
Change Line Style : Right/Left/Top/Bottom as single and change color to White.
I experienced this problem when I updated a Stored procedure. I changed the Description field that I was pulling onto the report from a VARCHAR(100) to a VARCHAR(150) inline with a requested change. The Crystal report in preview mode had stored old limit of 100 characters and was truncating the label. This was rectified when I verified the database again.
Database Tab -> Verify Database
I too discovered this too. Only happened in HTML view. I did a few things which for 3 blocks I needed to do different and tried numerous scenarios to choose the best to go with.
- Format text from left justufied to justified
- Grip the right edge of the text box and pulled it in a tick from the right margin
- Switched the font from Times New Roman to another (wierd)
- Exporting from BI LP as a CR RPT and exported from the CR 2013 client to PDF
- Change font size - We had an "and / or" midline and changed it to "and/or"
We went with the justified alignment since it was close to a full line and didn't look different than original.
Lots of wierd workarounds that rectified it. To me, it's indicating a system upgrade glitch in the report.
Hope what I found helps others.
If you tried all the methods and still not working, you can try the following:
Local StringVar inString := 'Your text string here.......';
Local NumberVar strLen := Length (inString);
Local StringVar result := "";
Local NumberVar maxLen := 45; // adjust the length of text per line
Local NumberVar idx := 0;
Local NumberVar proceed := 0;
While strLen > maxLen Do
(
proceed := 1;
idx := maxLen;
While (mid(inString,idx,1) <> " " and idx > 1) Do
(
idx := idx -1;
);
if (idx = 1) then
result := result + mid(inString,1,maxlen) + chr(10)
else
(
result := result + mid(inString, 1, idx-1)+ chr(10);
strLen := strLen-idx;
inString := mid(inString, idx+1, strLen)
)
);
if proceed = 1 then
(
result := result + inString
)
else
(
result := inString
);
result
In one environment with Crystal Reports it was a help for us to set the registry key: ForceLargerFonts = 0
How to find?
For 64 bit version of MS Windows:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\Export\PDF
For 32 bit version of MS Windows:
HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\Export\PDF
Please see also the following solution at
https://apps.support.sap.com/sap/support/knowledge/public/en/0001835763
This is a difficult problem that you have to attack from 3 different fronts:
Software Hot Fix
Default Printer
Form Authoring
Software Hot Fix: You'll need to download the CRRuntime that includes Hot Fix 20. This Hot Fix addresses truncation problems when making a PDF. You can find it at http://downloads.businessobjects.com/akdlm/crnetruntime/clickonce/CRRuntime_64bit_13_0_20.msi
Default Printer: The printer you use when authoring a report must match a printer where you are rendering a report. On our servers, there are no printers installed except the Microsoft XPS Document Writer. Be sure to select that as you default printer when writing the report.
Form Authoring: When you add a database field to your report, don't drag it from the field explorer onto the design surface. First insert a text object onto the design surface. When you've positioned and resized the Text Object the way you like it, drag the database field onto the Text Object. You'll see the name of the database item in curly braces appear in the Text Object. For whatever reason, the database field will wrap better when it is enclosed by a Text Object.
This got me literally stressed for a whole night!!
What worked for me was this:
if you are using crystal reports with dataset (linked to a dataset),most likely you changed the length of the field in the database. so if the length was 10 and you adjust to 20 for instance, no matter what you do, the report is reading the "Old" dataset with the field of length 10 characters and truncating it at 10 (I don't know why it did that)...believe it or not I just copied the query from my "Old" dataset,created a new dataset and VOILA!!! it worked like charm...

SSRS 2005 with matrix and list shows blank page between every data page when printing or exporting to PDF

I am using SQL Server Reporting Services 2005 - I have created a portrait A4 report 8.5in by 11in.
The report consists of a header, body and a footer.
The body consists of a number of textboxes in a 2 column layout and underneath them a matrix placed onto a list.
The matrix consits of 2 fixed rows (with 1 fixed textual column in the top row and 2 dataset field columns in the bottom one) and a number of columns (each with a width of 0.875in and data taken from different dataset fields). I use the group expression =Ceiling(RowNumber(Nothing)/5) on the list, to make the matrix columns start below the previous ones every 5 repeated columns.
The problem I am facing is that a blank page (with only header and footer) is appearing between every page of report data when I export the report to PDF or print it physically, if the matrix spans more than one page of data. There is plenty of room for the columns of the matrix on the page. I have tried the following, but to no avail:
1) I checked that Page Width (8.5in) >= Body Width (7.20833in) + Left Margin (0) + Right Margin (0)
2) I checked that Page Height (11in) >= Page.TopMargin (0) + Header.Height (2in) + Body.Height (6.60417in) + Footer.Height (0.89583in) + Page.BottomMargin (0)
3) I played around with various margin values, ranging from 0in to 0.5in for the left, right, top and bottom margins.
4) I set all textboxes' CanGrow property to false. This also has the undesirable effect of chopping out the text when it cannot fit, but even so, the blank page problem still occurs.
5) I placed the list and the matrix together in a rectangle with the blank space (to the right of the matrix) outside the rectangle.
The only thing that stops the blank pages from appearing is changing the list grouping expression to =Ceiling(RowNumber(Nothing)/2), i.e. make the matrix start a new "table" every 2 repeated columns (rather than 5). This, however, I do not understand, as there is plenty of space for 3 other columns to their right and it is odd and untidy to just put 2!!
I would greatly appreciate any help in this!
Thanks in advance!
Tim
For anybody who is having a similar problem in SSRS 2008, I found the only way to fix this was to set the property named ConsumeContainerWhitespace on the Report itself to true.
In my case the issue was that the matrix on the page was narrow in design mode with a lot of whitespace to the right. When rendered, the matrix was rendered much wider (due to the data) but the renderer would also include the whitespace, causing the report to be much wider than the actual page.
If you set this property, the extra whitespace does not get rendered.
If I understand you correctly I've solved this problem before. The matrix claims extra white space, the solution I used is as follows:
You need to consume the white space.
[-------page width------]
[matrix][-textbox hack-]
I think you can set the textbox to be invisible
Note: When I attempted this in 2005, it only worked when the invisible textbox spanned the entire line.

Eliminate stray whitespace between textboxes on a report

I have 4 stacked textboxes in the body of an SSRS report and am getting a stray space / extra line between textboxes 3 & 4.
This is for an address block - name / title / email / website. Can't put it in a single textbox with intervening vbcrlf tokens because the email and website are links. I've tried formatting it to remove vertical spacing; also calculated the exact position by taking top + height to calculate the position. And of course I've tried positioning it so there are exactly 0 pixels between the text boxes. If I reverse the position of #3 & #4 the rendering looks the same so it isn't stray formatting characters in the data fields.
The solution is to wrap the stacked boxes in a rectangle.
I had this problem as well. It blew my mind until I started over on another part of the form. The new boxes worked perfectly until I moved them to the right of another set of text boxes which had some word wrap in them. I realized the wordwrapped boxes were directly related to the gaps I was seeing the set of textboxes to the right. I guess there's some kind of poor markup going on that tries to line things up horizontally and enclosing the set of textboxes in a rectangle protects them from it.
good idea on putting the info into a table - jumping off that idea - I'm going to construct a dynamic string in my query and output the dynamic string into a textbox. thank you for the idea, I don't know why I didn't think to do that.
Simpler thing is to just check text alignment - the default is "default" which appears to be centered. Changing the text box to the right to "left" fixed this problem for me.
Reduce padding property of the textbox.
Once dragging the textbox one closer to the other the tooltip shows convergence points between two textboxes - make tooltip show 0 points
it is best I could do to control the spacing