|
|
Crystal Reports:
Extracting just the report File Name from the File and Path special field
The "File and Path
Name" special field appeared for the first time in CR7. It is a
really useful way to have your Crystal Report always display the name of the rpt
file that generated the report. It is a very good standard for your
Crystal Reports.
However, sometimes the full path makes the field too
long and can provide unnecessary information. You can write a formula to
extract the filename only with:
Mid (Filename ,InstrRev
(Filename,"\") + 1 ) // plus 1 is to get the character
after the ‘\’
This uses three interesting functions in CR8
1) Filename is the special field. You can
find it in the function list under "Document Properties"
2) InstrRev is similar to Instr except that
it searches the string in reverse order. In this case it looks for the
last "\"
3) The Mid function without a third parameter
will get the remainder of the string.
Using this technique can help prevent the use of cryptic
filenames, in favor of more descriptive ones. Here are some general rules to
follow for filenames:
- Don't use underscores. These are often invisible when
part of a URL or on a printed page. They look like a space.
- Don't use spaces. Obviously, a trailing space will
create problems. But so will a space that precedes text. Spaces in the
middle can cause problems, too. Despite what Microsoft says, Windows does
not like spaces. Database environments are not good for spaces either,
especially if you are importing or exporting field names, files, etc. Also,
it's too easy to use a double space and that can appear to be a single
space.
- When using dates as part of the filename, use the
format yyyymmdd, as this facilitates sorting. For example, 20110816 but not
16082011.
- Avoid embedding too much information in the filename.
This will only lead to errors and confusion. For example, it's fine to have
a filename ajaxcorpsalesfigures2012 but as you add information to the
filename you make taxonomy increasingly complex.
- Use a standardized taxonomy. If, for example, the
company name precedes the type of info, then always do it that way. Use
salesfigures-ajaxcorp2011 if all similar files will be in the format
salesfigures-companynameyear, but however you do it be consistent. Don't
also have bradcorpsales2011sales figures.
If you have a mess of filenames you inherited from some taxonomy-challenged
predecessor, how can you hope to clean it up? Maybe the best you can do is fix
the ones that are most critical. To see what's what on your hard drive(s), we
have a great tool called
Report
Analyzer.
This is the ultimate documentation and analysis tool for
Crystal Reports administrators, server administrators, and others who need to
maintain electronic filing systems.

Originally developed as a Crystal Reports tool only, with its version 5
release Report Analyzer became a powerful tool for analyzing any data
repository.
Some key points:
- Generate summary and detailed documentation.
- Analyze report complexity metrics to assist with test plan development
and maintenance planning.
- Easy to use documentation explorer to browse and compare report design
settings.
Print report design diagrams.
- Print report data dictionaries.
- Extensive formula printouts including call trees, object cross
references, formatted listing, and conditional formulas.
- All documentation can be exported in a variety of formats including PDF,
HTML and Word.
- Uses Crystal Reports to produce the documentation, enabling complete
customization.
This article is copyrighted by Crystalkeen, Mindconnection, and Chelsea Technologies Ltd.
It may be freely copied and distributed as long as the
original copyright is displayed and no modifications are made to this
material. Extracts are permitted. The names Crystal Reports and Seagate
Info are trademarks owned by Business Objects. |