In my view which I am exporting to excel, I display the value of this variable
VeryGoodPercentage = subQst.Question.ReponseList.Where(
r => r.ReponseValeur == 4 &&
Model.SelectedGroupContactList.Select(c => c.ContaId).Contains(r.ContaId.Value)
).ToList().Count() * 100
/
denominator;
And I display this way
<td class=xl76 align=right width=69 style='width:52pt'>#Math.Round(VeryGoodPercentage)%</td>
When I display the view without exporting to excel, everything works just fine. But when I open the exported Excel file, I found the value of that variable not rounded.
For examlpe :
In the view : 36%
In the excel file : 0.36
I use this line to generate the file:
Response.AddHeader("Content-Type", "application/vnd.ms-excel");
As stated:
36% and 0.36 should be the same - just excel did not fomat this as a percentage or did indeed interpreted 36 as a percentage - which will result in 0.36 as a number.
I don't see that this is a rounding problem, it is formatting or input or both.
Depending on what values #Math.Round(VeryGoodPercentage) produce - 0.xx or XX.XX - with % sign or without, excel will interpret this differently.
Some examples:
=0.36 will result in a number of 0.36
=36 will result in a number of 36
no suprises so far, but now:
=0.36% will result to 0.0036
=36% will result to 0.36
BUT those were Formulars, now if you would just use F2 on an empty 'default' formatted cell and write into it:
36% -> you would format this as percentage, which would display this as 36%, but if you would format it as 'default', then it would be the number 0.36!
0.36% -> would behave like 36%
hope this clears more than it confuses ;) good luck to you!
edit: and to make this even more fuzzy, in my country . is the symbol for thounsands, so you would have to use , instead.
edit: with VBA you could setup your column or cell to use a specific numberformat like this:
Table1.Columns("A").NumberFormat = "0.00%"
I finally found the solution here
Format HTML table cell so that Excel formats as text?
just add this css param to the tag :
mso-number-format:Percent;
Related
One of my first posts, so I'll do my best. I've tried searching this, which is how I got this far..but I could use some help converting some time data in the form mm:ss.000 (that's milliseconds at the end) to seconds with a fraction at the end. For example, 2:15.45 should come out to 135.45.
This works:
t <- "02:15.45" (as.numeric(as.POSIXct(strptime(t, format = "%M:%OS"))) - as.numeric(as.POSIXct(strptime("0", format = "%S"))))
But this one, where I'm trying to use a column of my dataframe (originally in character form) does not work:
starttimesFPsnapjumps <- FPsnapjumps$start (as.numeric(as.POSIXct(strptime(starttimesFPsnapjumps, format = "%M:%OS"))) - as.numeric(as.POSIXct(strptime("0", format = "%S"))))
Perhaps it's because my numbers in the column have an extra 0 - they are mm:ss.000. Any thoughts? Thanks in advance.
I have a measure in Tabular that calculates an amount I want the display to be like below :
1 990K
I tried to use FORMAT but in vain.
MyMeasure :=FORMAT ( SUM(MyTable[Salary]), "#, 0.,,.0#K" )& "€"
Try the following in the Properties :
#,##0, K€
I'm trying to calculate a row value based on the previous row value in the same column within a report expression. I can't precalculate this from database since starting point of calculation is dependent from input parameters and values in a table should be recalculated dynamically within report itself.
In Excel analogical data and formula look like as it is shown below (starting point is always 100):
B C D E
Price PreviousPrice CalcValue Formula
1 NULL NULL 100
2 2.6 2.5 104 B2/C2*D1
3 2.55 2.6 102 B3/C3*D2
4 2.6 2.55 104 B4/C4*D3
5 2.625 2.6 105 B5/C5*D4
6 2.65 2.625 106 B6/C6*D5
7 2.675 2.65 107 B7/C7*D6
I tried to calculate expected values ("CalcValue" is the name of column where expression is set) like this:
=Fields!Price.Value/ PreviousPrice.Value * Previous(reportitems("CalcValue").Value))
but got an error "Aggregate functions can be used only on report items contained in page headers and footers"
Can you please advice whether expected result is achievable in my case and suggest a solution?
Thank you in advance!
Sadly I'm still facing with issue: calculated column does not consider previous calculated value. E.g., I added CalcVal field with 100 as default and tried to calculate using above approach, like: =previous(runningValue(Fields!CalcVal.Value, sum, "DataSet1") ) * Fields!Price.Value/Fields!PreviousPrice.Value.
But in this case it always multiples Fields!Price.Value/Fields!PreviousPrice.Value by 100..
For example CalcVal on Fly always show 200
=previous(runningValue(Fields!CalcVal.Value, sum, "DataSet1")) * 2
https://imgur.com/Wtg3Wsg
I tried with your sample data, here is how I achieved the results
Formula to use, You might have to take care of null values
=Fields!Price.Value/(Fields!PreviousPrice.Value*Previous(Fields!CalcValue.Value))
Edit: Update to answer after Op's comment
CalcValue is caluated with below formula i.e on the fly
=RunningValue(CountDistinct("Tablix6"),Count,"Tablix6"*100
and then Final value as below
=Fields!Price.Value/(Fields!PreviousPrice.Value*
Previous(RunningValue(CountDistinct("Tablix6"),Count,"Tablix6"))*100)
I have data as below:
241 97,5 143,5 17,5 21
203 90 113 8 23
I've loaded it to a hive table, and put data type as double but I've lost precision of data
For example 97,5 become 97,0
Perhaps it's a problem with the comma but I cant change my input file.
I've also tried to change the data type to string, it still the same but after I needed sum function it cast it to decimal I think so those values doesn't count at all.
In my webpage, I am using PHPexcel 1.8 to generate excel files. Now I am facing an issue which describes below.
I have some date values in the format dd/mm/yyyy. The value is coming. But it shows with a single quote(') at the begining.
I tried many solutions. But none helps me out.
My sample code portion is given below
$cnt = 1;
foreach($gluuidArr as $uuid){
$this -> excel_180->getActiveSheet() ->setCellValue('A'.$cnt,$aVal);
$this -> excel_180->getActiveSheet() ->setCellValue('B'.$cnt,$bVal);
$this -> excel_180 -> getActiveSheet() -> setCellValue('C'.$cnt, $cVal);
$this -> excel_180->getActiveSheet() ->setCellValueExplicit('D'.$cnt,$dVal, PHPExcel_Cell_DataType::TYPE_STRING);
$this -> excel_180 -> getActiveSheet() -> setCellValue('E'.$cnt, $eVal);
$cnt += 1;
}
where $aVal, $bVal,.. are declaring inside the loop and $eval contains date in dd/mm/yyyy format
suppose the date is 20/05/2016, when click on the excel cell, it will show like '20/05/2016
I have tried
$this -> excel_180->getActiveSheet()->getStyle('E'.$cnt)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY);
But no luck.
Please help me to get rid of this issue. Any help could be appreciated.
That's because you're not storing a date, you're storing a string that happens to represent a date to human beings. MS Excel doesn't store dates as strings, but as floats, representing the number of days since 1st January 1900 (or 1st January 1904 on the Mac version)
If you want to store a date/time value in PHPExcel, then you need to convert that date/time to an MS Excel timestsamp value, and then set a format mask for the cell indicating how you want it to be displayed.
This is all explained in the PHPExcel Documentation and demonstrated in the Examples