How do you to edit a formula that is not a formula field? I can pick them in the foruma editor dropdown but that does not change the entry in the dropdown or code below.
I have a report I need to pull the logic from. The display clearly shows many #formula output fields and I can view the logic behind them. Some of the formulas reference other formulas that I can not find the definition of.
In formula editor for field: #field1
StringVar item:={table1.column1};
if item = 1 then
{#column2transformed}
else
" "
Where is {#column2transformed} defined if not on the main report display? I can find it in the selection list with an "X.1" icon next to it. I know which database field it is referencing in this simple example but can not afford to make assumptions about how the data is transformed.
In Crystal Reports formulas {#something} indicates a reference to a Formula Field that has the name of something.
The # symbol is used to signify the field name used in the braces is a Formula Field. There are other symbols used for other types of fields as well.
? is used for Parameter Fields
# is used for Running Total Fields
# is used for Formula Fields
% is used for SQL Expression Fields
I would also recommend you name your Formula Fields more descriptively. Names such as #something and #Field1 can become very confusing in the long-run. Especially in discussions such as this where it isn't always apparent if the word used is a literal name or generalized expression.
The file I was working with was version 7, I was editing with version 8.5, using version 9 fixed this bug/issue.
Related
Need to show the SSRS currency as CAD 200,000.00 but not able to achieve the same.
Changed the text box properties to Custom and Format as "C".
If the language is passed "en-US" or "en-CA" the format remains the same i.e. $200,000.00. Please Help!
Pretty easy to fix if you did a bit of research. I have an option that should work for you. First, you can set the textbox value as an expression and simply add the CAD to the front of the value. Then, you'll need to format the field as a decimal using the FORMAT function.
="CAD " & FORMAT(Fields!myField.Value, "###,###.##")
This expression should fill your needs.
Edit based on comment: After a very quick Google search, I found that you cannot avoid some form of hard coding if you intend to pass the currency format based on a report language. You'll need to include the following expression:
=FORMAT(Fields!myField.Value, "c")
This will format the field as a currency. In order to have the language passed from the report language, you need to turn on advanced mode. Below, step 1 shows where to turn on advanced mode. Step 2 shows where to change the language of the report. This is the report properties which are accessed when clicking anywhere outside of the report in the report window.
Here I tried it with CA-fr.
I have a column in my report that I want to hide based on an expression:
=IIF((ReportItems!Textbox16.Value ="USD" OR Parameters!BinderID.Value=10263 OR Parameters!BinderID.Value=10536 OR Parameters!BinderID.Value=10718 OR Parameters!BinderID.Value=10248 OR Parameters!BinderID.Value=10535 OR Parameters!BinderID.Value=10960),True,False)
When I run the report the hidden expression is working very well: the column is hidden. However, when I export to Excel the column reappears while it shouldn't.
This discussion would suggest it cannot be done, and would require a work around such as a separate report with only the columns wanted.
I do not normally work with crystal, but I have spent nearly 2 days looking for a way to do this.
The problem is that I have a number of lines of text that need to show on a report, but need to cut off after 8 lines and show a 'more' prompt to inform the user that they need to go look at the rest of the details online. This was originally handled by storing the data as individual lines already wrap to size and counting the lines with a formula and conditionally showing a separate 'more' field. They have since added the ability to use html to the text, but this made the current way of doing things wrap incorrectly and show the html mark up.
I wrote a database function to combine the text into a single field and use the HTML text interpretation to display it correctly on 7 other reports that do not limit the text length, and the max line count works great for limiting the text size, I just can't figure out how to show the 'more' prompt when needed.
Any suggestions would be greatly appreciated.
GrumpyGeek,
If your database function now combines the text into a single field does this mean the original way, with the separated lines, is still stored? If so, why not add another calculated field called 'line-count' that tallies the old line-based data?
So you'd still have your new combined HTML field and this new field that you could use to show the 'more' button when 'line-count > x'?
Alternatively, another option might work, but would be a bit touchy. That is to make the formula that shows the more button trigger when the field length exceeds x. The catch is that html mark-up isn't displayed, and heavy use of it would skew the amount of text required before you should show the 'more' button. Put another way, a field with very heavy use of mark-up ( and tags) might force the 'more' button earlier than it should. Unless you could somehow make either your 'line-count' calculated field exclude the mark-up OR make the length calculation do the same.
This would be possible if MSSQL or Crystal Reports could run regex to strip the mark-up.
If NONE of the above works, the only other thing I can suggest is to look into UDFs. Crystal allows you to load an external library that you write. These will read functions you write and show them in the function list inside Crystal. If you do this, then you could easily write a routine that strips the HTML and calculates when the more button should be shown.
Good luck with it.
Ideally, there would be a property of the DB field that would return its displayed line count. Unfortunately, there is no such property.
You could try counting the # of line ending characters (e.g. carriage return, line feed). If they are > 7 then show the hyperlink. In a HTML situation, you have to count ending elements (e.g. ). You could make use of a RegEx UFL to make it easier to identify the elements.
Probably the easiest route is to the DB to calculate the # of lines and return that as another field. Use this field to hide/show the hyperlink.
use strict
use Spreadsheet::WriteExcel;
my $Workbook = Spreadsheet::WriteExcel->new('cw.xls');
my $Worksheet = $Workbook->add_worksheet('MRD');
my $Formula= "A10+B10/2";
$Worksheet->write_formula(1,2,'='.($Formula));
exit;
Error getting:
Couldn't parse formula: =A10+B10/2;
Note : In the Formula that I am using contain across sheet data calling.
When I am Pasting it in the excel sheet manually its working fine but through program I am unable to put it in the sheet.
Please if any one came across this problem or has solution let me know.
If you see the documentation of Spreadsheet::WriteExcel module, it states in the DIAGNOSTICS section that:
Couldn't parse formula ...
There are a large number of warnings which relate to badly formed formulas and functions. See the "FORMULAS AND FUNCTIONS IN EXCEL" section for suggestions on how to avoid these errors. You should also check the formula in Excel to ensure that it is valid.
There is no problem storing a formula in a variable and passing it to write_formula(). In fact your own snippet above proves that it works.
So the problem is with the formula that you are trying to write. Since you haven't posted the formula it is hard to guess what the problem might be but here are some formula debugging tips from the docs:
Verify that the formula works in Excel (or Gnumeric or OpenOffice.org).
Ensure that it isn't on the Caveats list shown above. (In the docs).
Ensure that cell references and formula names are in uppercase.
Ensure that you are using ':' as the range operator, A1:A4.
Ensure that you are using ',' as the union operator, SUM(1,2,3).
Ensure that the function is in the above table. (In the docs).
P.S. The leading '=' isn't required when you are using write_formula() so you can just use:
$Worksheet->write_formula(1, 2, $Formula);
I have a crystal report which contains a list of absolutely referenced text files. There is one text file referenced in each body line.
e.g.
line1 c:\file1.txt
line2 c:\file2.txt
Is there any way to display the contents of these files in Crystal?
i.e. I would like each crystal body line to show the text from the referenced text file.
I'm using Crystal reports 11 with a non-standard database connector (dataflex).
You would need to set up a file dsn (in XP it's under Control Panel/Administrative Tools/Datasources (ODBC)) and then use the file dsn (Microsoft Text Driver) for the datasource as an ODBC(RDO) connection.
I set this test scenario up on mine like the following:
**File 1**
column1
1row1
1row2
1row3
**File 2**
column1
2row1
2row2
2row3
I set up the file dsn to point to the c drive and in the datasource screen I added file1.txt and file2.txt to the selected tables. Then the easiest thing to do is clear the links of the tables so that it pulls every row. It will warn you that there are multiple starting points. I don't generally recomend this, but it will work in this case and since it's not reporting off a database it probably isn't the end of the world. If you disregard the starting point message then add the fields to the report, when you run it you should get the following output:
1row1 2row1
1row1 2row2
1row1 2row3
1row2 2row1
1row2 2row2
1row2 2row3
1row3 2row1
1row3 2row2
1row3 2row3
From this you can change your grouping to get the output that you need.
You can also use this same connect against subreports instead of doing this linking where you have the main report pull the info from file1.txt and then put a subreport in the report footer that pulls from file2.txt. This option won't have the text collated, but you'd still have it in the same report.
Hope this helps some.
It's easier than you think. I just set up one myself before I wrote this to make sure I was giving you the right steps. Using CR version XI and a .txt file, I followed these steps:
For each text file you want to import, make a subsection in your report (i.e. DetailsA, DetailsB, etc.). If your list of text files is constantly changing (and I don't think it is, based on your description), you'll need another method.
Make sure your text file is comma delimited and the first row contains field names. If these text files are actually text (i.e. not tables), then just put a dummy variable name in the first row so Crystal will see the text as a table of data with just 1 row.
For each text file you want to display, create a new Subreport (Insert->Subreport)
In the database selection menu, go to "Create New Connection"->"Access/Excel (DAO)"
Under 'database type', you'll see a 'text' option at the bottom of the screen.
Choose your file.
Relax! (I'm in a good mood this morning, don't know why)
I guess if you have a function that takes a file name as an argument and returns the contents of that file - you could use that function in a Crystal Report formula.
I am not familiar with the current CR, it has been years since I last used it (I last used version 8). In the versions I did use, such a function was not built in. What you would have to do back then, was to create a UFL (user function library) containing the functions you needed. If I remember correctly, you had to do this using COM.
In this day and age, I guess you can extend CR using some other mechanism, perhaps writing .NET code?
I suggest you search the CR documentation for the term UFL.
Another suggestion, then:
Create a new table FILECONTENTS (filename varchar primary key, contents blob)
Create a script that on a schedule populates this table with the filenames and contents of all the files (assuming that there is a finite number of files, and that you have a way of knowing about them)
Modify the report datasource query to join it with the FILECONTENTS table, and add the contents field to the report.
You could setup a file dsn. But this is geared toward tabular file data, not text.
How big are these text files? You want to display the entire contents of each file?
There is probably no easy way to dynamically read in a file from within crystal. You will most likely have to push a dataset to the report which contains the file contents.