Im using Jaspersoft Studio to design my reports and JasperReports Server to publish them for my php web application.
In one of my reports it contains some float numbers displayed in the format 103.12 but i want it to be displayed like this: 103,12 and when it reaches 5 digits like this 50 000,14.
After some reading i tried to set the local to french but nothing changed.
And when i change the pattern in the jasperstudio to # ###,00 i get this :
and for the old pattern #,###.00 that comes by default in the jasperstudio i get this :
Analysis
We dealt with this as well. The locale which is being set in the JasperReports server login page is just for the admin UI, not for the report generation.
Solution
If you want to have a different locale set on your server, you need to set it in the JasperReports server config in /jasperreport-path/apache-tomcat/bin/setenv.sh (add it into one of those JAVA_OPTS):
-Duser.language=FR -Duser.country=FR
Now all locale-specific settings will be correctly configured and putting #,###.00 as a pattern for the field will be translated to your locale format by default in the server. So for the french format would be displayed like this: 1 000,12.
Related
Is there a server side function in SFCC to get Locale? Thank you!!!
I am localizing a sfcc site, and need to update the en_gb locale in thousands of hard coded strings (in a xml file obtained from Merchant Tools > Content > Import & Export) to server side code that will dynamically insert the correct locale, i.e. en_gb, fr_fr, etc. I know there are a few server side functions like $URL()$ that can run before content is rendered. Is there one to get the Locale?
here is what I have now... https://www.example.com/en_gb/holiday-sale-event/?prefn1=productType&prefv1=Shoes
ideally, I'm looking for something like: https://www.example.com/$Locale()$/holiday-sale-event/?prefn1=productType&prefv1=Shoes
Expected results would be:
https://www.example.com/en_gb/holiday-sale-event/?prefn1=productType&prefv1=Shoes
https://www.example.com/en_nl/holiday-sale-event/?prefn1=productType&prefv1=Shoes
https://www.example.com/fr_fr/holiday-sale-event/?prefn1=productType&prefv1=Shoes
https://www.example.com/de_de/holiday-sale-event/?prefn1=productType&prefv1=Shoes
...etc., depending on locale.
You should be using $url()$ to generate the URL which will automatically populate the correct locale string in the URL.
Assuming that the above examples are links for a refined category search within a category with the ID: holiday-sales-event Then your first example would be represented as such:
$url(Search-Show,cgid,holiday-sales-event,prefn1,productType,prefv1,shoes)$
This would produce the correct localized URL for whatever locale context the content is being rendered for.
Since the “holiday-sales-event” portion of the URL is likely to be localized itself, then your intended approach would result in either 404s or redirects at the very least.
you can get the current locale with request.locale
var currentLocale = request.locale;
I'm using Eclispse BIRT version 4.7.0 to run reports in various formats,
My report has a date field in the following format: 'DD/MM/YYYY/'
When I run the report through the Eclipse BIRT Designer application, with the WebViewer, or to PDF for example, the date comes printed in the expected format, for example it prints '05/07/2006'
But when I run the report using the Runtime Engine (via command line) it prints the same date value like this: 'Jul, 5, 2006'
Does anyone know why this is happening and how to solve it?
Thank you!
I've spent many hours searching on Internet but kind of desperate at this point.
We have a report having two DataSet fields defined as
Date_Difference = Round((DateDiff("d", Fields!StartDate.Value, Fields!EndDate.Value))* Fields!ProjectStatusPct.Value)
status_date = CDate(DateAdd("d", Fields!Date_Difference.Value, Fields!StartDate.Value))
Both SSRS and BIDS are installed on the same server(VM, Windows Server 2008 R2). The Region, Language, Format, everything i can think of on the machine is configured as en_US.
The language in report property is en-US, also i have this en-US defined in the report code to be sure.
<Language>en-US</Language>
Also in reportViewer.aspx, i changed
<%# Page Language="C#" AutoEventWireup="true" Inherits="Microsoft.ReportingServices.WebServer.ReportViewerPage"%>
to
<%# Page Language="C#" AutoEventWireup="true" Inherits="Microsoft.ReportingServices.WebServer.ReportViewerPage" Culture="en-US"%>
as suggested by some post.
The data source server(MSSQL 2008, on the same machine) Language is en-US as well.
The report looks fine in the BIDS designer. However, when i deploy it to the server, the date format get messed up. The Reporting Server takes MM/dd/yyyy(US format) as dd/MM/yyyy (Canada format). As a result, the status_date field is always generating wrong date, or NULL if it comes to a date like 03/31/2012
When I look at the SSRS log files, the header always displays as
<Header><Product>Microsoft SQL Server Reporting Services Version 2007.0100.5500.00 ((Katmai_PCU_Main).110922-0336 )</Product><Locale>English (Canada)</Locale><TimeZone>Pacific Daylight Time</TimeZone><Path>C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\Logfiles\ReportServerService__06_07_2012_16_30_41.log</Path><SystemName>KAM1ODDBS06</SystemName><OSName>Microsoft Windows NT 6.1.7601 Service Pack 1</OSName><OSVersion>6.1.7601</OSVersion><ProcessID>1160</ProcessID></Header>rshost!rshost!ec0!06/07/2012-16:30:41:: i INFO: CLR runtime is initialized.
So I think the BIDS takes the local machine's language setup then it handles the date correctly.
More information :
the brower(IE) 's language is en_US
when i deploy the report to other reporting server having en_US locale, it works.
My question is, how to change this reporting server's locale to en_US as well?
I think setting the Server Language might fix it. There are two levels of assigning the locale one is at the Report Level and other at the TextBox or field level if you may. Check what is there in your field. Just in case you might be also interested in this one http://technet.microsoft.com/en-us/library/ms155064(v=sql.100).aspx it talks about the case which you have described.
I've designed a crystal report that will be sent to a specific (barcode) printer through a web interface. Allowing the report to be generated in the standard crystal report viewer was causing issues, so I am now using the code-behind to send the report directly to the printer.
ReportDocument Report = new ReportDocument();
ParameterDiscreteValue Order = new ParameterDiscreteValue();
Order.Value = Convert.ToInt32(txtOrder);
Report.Load(reportPath);
Report.SetParameterValue("OrderNo", Order);
PageMargins margins;
margins = Report.PrintOptions.PageMargins;
margins.bottomMargin = 0;
margins.leftMargin = 0;
margins.rightMargin = 0;
margins.topMargin = 0;
Report.PrintOptions.ApplyPageMargins(margins);
Report.PrintOptions.PrinterName = "\\\\printserver\\Zebra Z6M Plus (300dpi)";
Report.PrintToPrinter(1, false, PageNum, PageNum);
Report.Close();
When printed from the designer (CRXI) everything works fine but when the web interface sends the job to a printer (any printer) it changes the font to Times New Roman which messes up all of the field sizes. If I use the standard .NET report viewer it uses the correct font, so I'm pretty sure the change is being caused by creating/using the ReportDocument.
How can I send the report directly to a print without it defaulting the fonts back to Times New Roman?
This idea occured to me:
Instead of sending the report straight from Crystal to the printer, what if you use some kind of middleman, i.e. export the .rpt to .pdf first, then print the PDF?
(Yes, it would be a very "wooden tables" tables approach, but if it works, it works.)
While it seemed like the special font I was using had been included on every server imaginable, I was never able to get it to work through the web interface.
I ended up finding a standard windows font that mostly suited the needs of this project and have given up on trying to beat this problem.
You need use RAS SDK API. Crystal Reports for Visual Studio 2010 (v13) include this api. (This code don't work in Crystal Reports for Visual Studio 2005... I don't have info about other versions)
Add this references to your existing code:
CrystalDecisions.ReportAppServer.ClientDoc
CrystalDecisions.ReportAppServer.Controllers
CrystalDecisions.ReportAppServer.ReportDefModel
And use this code (VB... sorry)
Using rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rpt.Load(file, CrystalDecisions.[Shared].OpenReportMethod.OpenReportByTempCopy)
rpt.SetDataSource(_ReportSource)
Dim options As New CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions
options.Collated = _Collate
options.NumberOfCopies = _Copies
' TODO: Implement_startPageN and _endPageN
Dim optPrint As CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions
optPrint = rpt.ReportClientDocument.PrintOutputController.GetPrintOptions
optPrint.PrinterName = _PrinterName rpt.ReportClientDocument.PrintOutputController.ModifyPrintOptions(optPrint)
rpt.ReportClientDocument.PrintOutputController.PrintReport(options)
rpt.Close()
End Using
I was trying to change Crystal Report Font according to data that will be shown on the report.
I use Formate Formula to change the font using flags Condition.
if({?vIsRightToLeft}=true)then
"Attari Font"
Else
"Arial"
What is a good method to localize labels (column headings, field labels, headers/footers, etc) on Crystal Reports?
We are currently on XI R2 SP4 but are looking to migrate to 2008. It looks like 2008 offers better localization of the viewer UI. Does it have a content localization story?
Found a way to for localization of values such as DateTimes in Crystal Reports.
For instance if date is Aug-2009 and culture is French then would display as août-2009.
All this WITHOUT switching the current Thread culture to French.
Relevant Code snippet (example):
//Locale must be set BEFORE report is opened
if (this.IsEnglish)
{
ReportDoc.ReportClientDocument.PreferredViewingLocaleID =
CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishCanada;
ReportDoc.ReportClientDocument.LocaleID =
CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishCanada;
ReportDoc.ReportClientDocument.ProductLocaleID =
CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishCanada;
}
else
{
ReportDoc.ReportClientDocument.PreferredViewingLocaleID =
CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleFrenchCanada;
ReportDoc.ReportClientDocument.LocaleID =
CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleFrenchCanada;
ReportDoc.ReportClientDocument.ProductLocaleID =
CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleFrenchCanada;
}
//Load the report from file path
ReportDoc.Load(reportPath.ToString());
The two options that I can think of are: 1) Have a separate report for each localized version (this gets ugly quick and I don't recommend it very highly) or 2) Have the report generated from an application (say a c# windows/web app) and then you can localize using .net's localization standards and setting all of the localized text (read in from resource files) in the code.
I am not certain about 2008 but we are also on XI R2. We have localized reports for each language but only because we * know * that we will only need three different localized versions.
A client asked me to do develop a localization strategy for them. I've been meaning to write an article on it. Thanks to you, I've done just that. http://www.cogniza.com/blog/?p=55
Edit:
I was able to use an embedded subreport (in the report-header section) that referenced a database of localization values. I would have added that to my posting, but it was quite complex.
Another option is to create a user-function library (UFL) that handles this tasks. Store the data in a database or XML file. Most likely, however, you will lose the ContentLocale functionality.
We finally got around to implementing report localization. Loading of Crystal Reports is already the laggiest/worst-performing part of the user experience in our app, so we wanted to avoid any performance impact. The other idea that informed our decision was that the translations won't change within a shipped release.
We developed an application that uses the Crystal Reports API (2008 - so there's no RDC) and works in two phases.
First phase is to scrape all of the text and output to an English .resx file. Toughest part of this is identifying translatable text within functions, and replacing embedded fields with tokens indicating "don't translate."
After the localized versions of the resx come back, the second phase of the app takes each report along with each resx and saves out new reports with English replaced with translated text. This also allowed us to switch out the fonts only in Japanese reports to MS Gothic, thereby avoiding the need to license a "universal" font. The Japanese characters in "universal" fonts (e.g. Arial Unicode MS) tend to look like crap.
The Crystal API is byzantine, and you need to be careful with edge cases around detecting translatable strings within functions and embedded fields. Be careful with the builtin fields like PageNofM, they aren't enclosed in curly braces (not to mention that you should replace this with Page {field} of {field} so "page" and "of" can be translated). One pointer, use the controllers to replace existing items with cloned/modified copies, you can't just modify the text content of items in place. Good luck if you go this route, but in the end we think it's the best option.
Single Crystal report Use for multiple language
if (CultureInfo.CurrentCulture.Name == "en-US")
{
(obj.ReportDefinition.ReportObjects["lbleverest"] as TextObject).Text = resBundle.GetString("Localization", "everest");
(obj.ReportDefinition.ReportObjects["lblmandlicode"] as TextObject).Text = resBundle.GetString("Localization", "SocietyCode");
(obj.ReportDefinition.ReportObjects["MandliName1"] as FieldObject).ApplyFont(new Font(resBundle.GetString("Localization", "Font"), Convert.ToInt32(resBundle.GetString("Localization", "FontSize")), FontStyle.Regular));
(obj.ReportDefinition.ReportObjects["shortName1"] as FieldObject).ApplyFont(new Font(resBundle.GetString("Localization", "Font"), Convert.ToInt32(resBundle.GetString("Localization", "FontSize")), FontStyle.Regular));
}
else
{
(obj.ReportDefinition.ReportObjects["lbleverest"] as TextObject).Text = resBundle.GetString("Localization", "everest");
(obj.ReportDefinition.ReportObjects["lblmandlicode"] as TextObject).Text = resBundle.GetString("Localization", "SocietyCode");
(obj.ReportDefinition.ReportObjects["MandliName1"] as FieldObject).ApplyFont(new Font(resBundle.GetString("Localization", "Font"), Convert.ToInt32(resBundle.GetString("Localization", "FontSize")), FontStyle.Regular));
(obj.ReportDefinition.ReportObjects["shortName1"] as FieldObject).ApplyFont(new Font(resBundle.GetString("Localization", "Font"), Convert.ToInt32(resBundle.GetString("Localization", "FontSize")), FontStyle.Regular));
}
obj.DataDefinition.FormulaFields["lang"].Text = "'" + CultureInfo.CurrentCulture.Name + "'";
cv.crystalReportViewer1.ReportSource = obj;
cv.Show();