Insert formatted values as currency type while using EPPlus - format

I am using format:
type ="$###,###,##0.00"
for currency and assigning the format type to the worksheet cells
eg.
wrkSheet.Cells[0].Style.Numberformat.Format = formatType;
But this is inserted as text type in excel.
I want this to be inserted as Currency or Number in order to continue to do analysis on the values inserted (sort, sum etc).
Currently as it is text type validations do not hold correct.
Is there any way to force the type in which the formatted values can be inserted?

Your formatting is correct. You needs to covert values to its native types
Use this code, it should work:
using (var package = new ExcelPackage())
{
var worksheet = package.Workbook.Worksheets.Add("Sales list - ");
worksheet.Cells[1, 1].Style.Numberformat.Format = "$###,###,##0.00";
worksheet.Cells[1, 1].Value =Convert.ToDecimal(24558.4780);
package.SaveAs(new FileInfo(path));
}

Indices start from 1 in Excel.
This code
using (var package = new ExcelPackage())
{
var worksheet = package.Workbook.Worksheets.Add("Sales list - ");
worksheet.Cells[1, 1].Style.Numberformat.Format = "$###,###,##0.00";
worksheet.Cells[1, 1].Value = 24558.4780;
package.SaveAs(new FileInfo(path));
}
produces $24 558,48 for me

Related

Oracle APEX - Interactive Grid - get the return value of the select list from each record

My Interactive Grid has column caled "EMPL_STAT1".
I use the code below to get the return value of the select list from selected record.
Works fine but I was wondering how to change that code to get the return value of the select list from each record (not selected only) in "EMPL_STAT1" column?
Could you give me any advice?
var reg = apex.region('ig_emp').widget();
var grid = reg.interactiveGrid("getViews","grid");
var model = reg.interactiveGrid("getViews","grid").model;
var selectedRecords = grid.getSelectedRecords();
for (i = 0; i < selectedRecords.length; i++)
{
record = model.getRecord(selectedRecords[i][0]);
itemcodeField = model.getFieldKey("EMPL_STAT1");
alert(record[itemcodeField].v);
}
The Javascript you shared, gets the selected row records only.
Let's say my IG's static ID is igTest
var model = apex.region("igTest").widget().interactiveGrid("getViews", "grid").model;
model.forEach(function(igrow) {
console.log(igrow[model.getFieldKey("FIRST_NAME")]);
});
This will loop through all the records in the IG.

How to remove or hide the data value not required from table in birt tool

How do I remove or hide the data value not required from table in birt tool?
I tried with the values it works in some places but now in groups which has multiple values.
I need to filter some of the values which should not be displayed in the data tab of the table.
I have a column which does not have any value that I need to filter out (But its not an empty value because when I check I got to know that it has some blank spaces). It should display only the columns with non-blank value.
How can I remove those columns from the data set.
You can of course try scripting the data source query but you can also run a script on the table when it is created to hide the empty column.
Try this script in the table's onCreate event:
var mycolumnCount = this.getRowData().getColumnCount();
var DisNull = false;
for(i=1;i<mycolumnCount;i++) {
var temp = this.getRowData().getColumnValue(i)
if(this.getRowData().getColumnValue(i) == "") {
DisNull = true;
}else{
DisNull = false;
i = mycolumnCount+1;
}
}
if(DisNull == true) {
this.getStyle().display = "none"
}

Using Variables for Column Names when Querying Parse.com Database

I have two Parse.com classes. I retrieve an array of values from Class1. The values are the names of the parse.com columns in Class2. After retrieving the desired object from Class2, I want to loop through getting the appropriate columns in Class2 like this:
Parse.initialize("KsUhcunt9PkSkvyRWXAeL", "ykLWdyBk6wAmOPC");
var CheckWait = Parse.Object.extend("CheckWait");
var query = new Parse.Query(CheckWait);
query.equalTo("objectId", "oMP9qf7MAj");
query.first({
success: function(object) {
$(".success").show();
var test = object.get("myArray[1]");
},
OK. So, if I replace myArray[1] with the appropriate column name, it retrieved the desired data. I tested the value contained in myArray[1] and it does contain the correct column name. If i set another variable = myArray[1] parse.com still returns "undefined".
If the contents of myArray[1] is a string "nickname", then the following are equivalent:
var nick1 = object.get("nickname");
var nick2 = object.get(myArray[1]);
The issue is that you passed the string "myArray[1]" instead of the expression myArray[1].

Bind Objects To DataGridview and Reorder Column

I want to bind the object list to dataGridView.
Now i want the desired column to be the way i definde them. i.e., I want the objects to be order the way i want.
Like
var dataSource = linkItemListCommon.Select(x => new DataToBind { Select = x.Default, FileName = x.Text, CurrentDate = x.Date+" "+x.Time , PreviousDate = string.Empty, Size = x.Size }).ToList();
var filenamesList = new BindingList<DataToBind>(dataSource);
dgvDownLoadMaster.DataSource = filenamesList;
I want the datagrid columns to be in the order that i define.
Like here i expect them to be in order given below:
Select FileName CurrentDate PreviousDate Size
But the column list is appearing not as per my requirements.
How to Do that.Please help.
Create columns by hand and then you can order them easily. You can add columns trough designer and just set each column DataPropertyName to corresponding field.
Or you can create each column programmatically:
var col = new DataGridViewTextBoxColumn();
col.DataPropertyName = "Select ";
col.HeaderText = "Select";
col.Name = "ColSelect";
dgvDownLoadMaster.Columns.Add(col);
you have to do this for each column and do it before databinding.

How to populate the table dynamically and correctly with Ajax?

I have a form where the user submits a query and then have a Servlet that processes this query and returns the results in XML. With this result trying to populate a table dynamically via Ajax, for such, I use the following code below.
var thead = $("<thead>");
var rowsTHead = $("<tr>");
var tbody = $("<tbody>");
var numberOfColumns;
$(xml).find("head").each(function(){
var variable = $(this).find("variable");
numberOfColumns = variable.length;
for (var i = 0; i < variable.length; i++){
var name = $(variable[i]).attr("name");
rowsTHead.append($("<th>").html(name));
}
});
thead.append(rowsTHead);
$(xml).find("result").each(function(){
var literal = $(this).find("literal");
var rowsTBody = $("<tr class=\"even\">");
literal.length = numberOfColumns;
for (var j = 0; j < literal.length; j++){
var tdBody = $("<td>");
tdBody.html($(literal[j]).text());
rowsTBody.append(tdBody);
}
tbody.append(rowsTBody);
});
$(".tablesorter").empty()
.append(thead)
.append(tbody);
This code works perfectly until it was used in a UNION query. When using a UNION the returned xml comes in the following way http://pastebin.com/y7hXK1Zy
As can be observed, this query has 4 variables that are: gn1, indication1, gn2, indication2.
What is going wrong is that the values of all the variables being written in columns corresponding to gn1 and indication1.
What I wish I was to write the value of each variable in its corresponding column. I wonder what should I change in my code to make this possible.
You need to respect the name values of the binding elements, and relate them back to the columns that you correctly built from parsing the element. When you are doing the find "literal", you are skipping the parsing of the binding elements. You should find "binding", respect the name and look up which column to use based on that, and then for each of those, find the "literal" elements for the actual values.

Resources