I am using UltraWinGrid and displaying the sum of the values using the SummaryRow. I need to display the maximum date in the summary row in MM-dd-yyyy format. Only date should be there. How to achieve this. Thanks in advance...
I got the answer form the site
http://www.csharp-examples.net/string-format-datetime/
SummarySettings SumSummary = new SummarySettings();
e.Layout.Bands[0].Columns["DateColumn"].AllowRowSummaries = AllowRowSummaries.False;
SumSummary = e.Layout.Bands[0].Summaries.Add(SummaryType.Minimum, e.Layout.Bands[0].Columns["DateColumn"]);
SumSummary.DisplayFormat = "{0:dd-MM-yyyy}";
I use pentaho report designer. I have got businessdate parameter in my prpt file. This has the value of the date range which is used to filter the sql query. I am able to handle and modify it while exporting to html however I have a problem in exporting to excel.
The date range comes in the formats below:
- BETWEEN {d '2014-01-01'} AND {d '2014-01-31'}
- IN ({d '2014-01-14'},{d '2014-01-15'}, {d '2014-01-19'} ,{d '2014-01-20'},{d '2014-01-21'})
I like to find out max and min date and display it. However in this case with excel, I am happy with displaying them separated with commas like shown below.
- 2014-01-01, 2014-01-31
- 2014-01-14, 2014-01-15, 2014-01-19, 2014-01-20, 2014-01-21
If I use the basic formula show below, it works in in excel but it does not work when I apply it to excel - formula section of the businessDate element in pentaho report designer.
=TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B4,"{d '",""), "BETWEEN", ""), "IN", ""),"'}",", "), " AND ", ""),")",""),"(",))
It does not have to be this way. I am happy with any method suggested to format this raw date range before printing to excel.
Thank you in advance.
After wasting a lot of time, I have found a way which works for all export types. As I said in my question, I was modifying date for html print by using "Structure Tab" --> Select "Master Report" --> "Attributes" Tab --> html -> "append-header" attribute.
<script type="text/javascript">
function init() {
var tableList = document.getElementsByTagName("table");
var businessDate = document.getElementById("businessDatePeriodSelected");
businessDate.innerHTML = businessDate.innerHTML+"testDateModified";
}
window.onload = init;
</script>
This piece of code does the job. However just for html. I needed to come up with something new. I was looking for a solution for excel and pdf exports as well.
HERE IS THE SOLUTION:
Click on "Data" tab next to the "Structure" tab on the right top side. You will see "Functions" in the tree. Right click and hit "Add functions". Select "Script" -->"Bean-Scripting Framework (BSF)". Select function created under Functions. Give it a name and add the code below to the "Expression" section. [This does not need a starting or ending tag]
/* businessdate is one of my parameters that I like to display on the report.
dataRow is automatically recognized by the interpreter which can be used for calling parameter values. It seems like came out of nowhere.*/
String value = dataRow.get("businessdate");
value= value.replaceAll("[^0-9\\-\\{\\}]", "");
value= value.replaceAll("[\\{]", ""); // replace all {
value= value.replaceAll("[\\}]", ","); // replace all }
value= value.substring(0, value.length()-1);
String[] dateArr = value.split(",");
return dateArr[0] +" - "+dateArr[dateArr.length-1];
The last thing you need to do is drag and drop your function somewhere suitable on your report. It will locate a textbox which will display the modified businessdate.
If you like to print a parameter on your pentaho report, this does the job for all exports (html, pdf and excel). You can also modify it before printing. This link pretty helpful as the syntax is slightly different at some points.
good luck.
After watching David Leedy's video on creating pdfs from xpages using iText - I tried to create a pdf of a form in one of our XPage apps. The form is basically a 2 column table with various data fields - name, address etc. All of the text fields display perfectly but not the date fields. Here is one example where I am trying to display the date of birth of the person (Person_dob) in cell 7 of my table.
var cell7 = new com.itextpdf.text.pdf.PdfPCell(new com.itextpdf.text.Paragraph(currdoc.getItemValueString("Person_dob")));
This displays a blank in the table cell, not the value of the date field; I have tried changing the code and used both getItemValueDate and getItemValue instead of getItemValueString but this crashes the pdf before it even creates. No doubt I am missing something obvious but I just cannot see it.
Use getItemValueDate() to get date as Date object and convert it to a string in locale date format with toLocaleDateString():
var date = currdoc.getItemValueDate("Person_dob");
if (date != null) {
var cell7 = new com.itextpdf.text.pdf.PdfPCell(new com.itextpdf.text.Paragraph(date.toLocaleDateString()));
}
If you wish more control over the date format then you can use SimpleDateFormat in instead:
var date = currdoc.getItemValueDate("Person_dob");
if (date != null) {
var datePattern = new java.text.SimpleDateFormat("yyyy-MM-dd");
var cell7 = new com.itextpdf.text.pdf.PdfPCell(new com.itextpdf.text.Paragraph(datePattern.format(date)));
}
I realized I have this with all combo box. I want it to have a default value so I tried...
TimeField field = new TimeField();
field.setFormat(DateTimeFormat.getFormat("HH:mm"));
field.setRawValue("10:00");
But when I open the section, the value does not get set. It is still blank.
I m found the solution. I used following format its woks.
private TimeField fromTime = new TimeField();
fromTime.setFormat(DateTimeFormat.getFormat("HH:mm"));
fromTime.setIncrement(1);
Time time = new Time();
time.setText("00:00");
fromTime.setValue(time);
fromTime.setTriggerAction(TriggerAction.ALL);
toolbar.add(fromTime);
I am trying to create a Date using the DocuSign API where it mimics the Text field with Validation set to Date and then one of the three support "Validation date mask". When I submit the api request using the ValidationPattern of "^[0-9]{4}/((|0)[1-9]|1[0-2])/((|0)[1-9]|[1-2][0-9]|3[0-1])$"...it does not give me the calendar selector like the when I drag a date in the form editor.
Date date = new Date();
date.DocumentId = "1";
date.PageNumber = "1";
date.RecipientId = "1";
date.XPosition = "100";
date.YPosition = "100";
date.TabLabel = "txtbx_code_date_yyyymmdd";
date.ValidationPattern = "^(|by DocuSign)[0-9]{4}\\/((|0)[1-9]|1[0-2])\\/((|0)[1-9]|[1-2][0-9]|3[0-1])$";
date.ValidationMessage = "YYYY/MM/DD";
What am I doing wrong?
Thanks
jlimited.
The Date tab is also know as "Date Signed" and is auto-populated with the date when the recipient/signer signs the document, you cannot make it editable to the user.
You can use a text tab with your validation pattern for your needs instead.