Showing posts with label Crystal Reports. Show all posts
Showing posts with label Crystal Reports. Show all posts

Wednesday, August 10, 2022

Crystal Reports Custom Report Function: Superscript Text generator.

 A simple custom report function for Crystal Reports that will take a numeric value and generate a string of UTF8 superscripts of the digits.


//font must be Arial Unicode MS or other font with Unicode support
//1 2 3 4 5 6 7 8 9 0
//Hex
// 2071 00B2 00B3 2074 2075 2076 2077 2078 2079 2070
//Dec
// 0185 0178 0179 8308 8309 8310 8311 8312 8313 8304
Function (numberVar SuperScriptNumber)
//If 1 thru 9 and then zero since we're not a zero based array
Local NumberVar Array subs := [0185,0178,0179,8308,8309,8310,8311,8312,8313,8304];
Local NumberVar x;
Local NumberVar DecValue;
Local StringVar NumString := ToText(SuperScriptNumber,0,"","");
Local StringVar SuperString := "";
For x:= 1 to Len(NumString) Do
(
	DecValue:= ToNumber(Mid(NumString,x,1));
	if DecValue = 0 then SuperString := SuperString + chrw(subs[10])
	else
	SuperString := SuperString + chrw(subs[decValue]);
);
SuperString

Wednesday, July 29, 2020

Python: Performing XSLT recursively on a directory of XML files

I've been using https://github.com/ajryan/RptToXml to extract out xml information from Crystal Reports. I then rip through the created xml files with xlst to provide detail information on how the reports are created.  This little python 3.5+ script uses https://www.saxonica.com/download/download_page.xml and will create html files from a directory tree containing xml files.  

TODO: Write an xxl file to convert Crystal Reports to Jasper Reports.


import os
import subprocess
import glob
from pathlib import Path
root_dir = r"C:\crystalxml"
xslFile = r"C:\Saxon\pretty.xsl"

for filename in glob.iglob(root_dir + '/**/*.xml', recursive=True):

 my_parts = filename.split("\\")
 justname = my_parts[-1].split('.')[0]
 my_dir = os.path.dirname(filename)
 newname = fr'{my_dir}\{justname}.html'
 cmd = fr'java -cp C:\Saxon\saxon-he-10.1.jar net.sf.saxon.Transform -t -s:"{filename}" -xsl:{xslFile} -o:"{newname}"'
 subprocess.call(cmd)

Friday, March 29, 2019

Crystal Report Tricks: Using special fields in formulas

When you want to use a special field in Crystal Reports in a formula, you can specify the special field  by using the special field name without spaces.  I admit I haven't tried them all, but in this case, the comments are multi-line and I wanted to grab just the first line.

split(ReportComments,chr(13))[1]




Friday, August 25, 2017

Crystal Reports 2016 User Function Library for i18n Translation.

While endeavoring to expand my knowledge of Crystal Reports Designer, I just finished uploading my experiment in creating a Crystal Reports User Function Library in C#.  I've placed the project in my GitHub account https://github.com/wiggick/CRUFL_I18N