PHPExcel set default Column Width - phpexcel

Today I had a little problem with excelphp.
I wanted to set the default width of the columns manually and only one single time.
I found a few solutions also here on stackoverflow which suggested to change the value for every single column (e.g. within a loop).
But I wanted to do it with a single command.

After browsing the source code I found out the following solution:
$phpExcelObject->getActiveSheet()->getDefaultColumnDimension()
->setWidth($myCustomWidth);
I hope that this helps anybody else ;)

Related

Assigning a list to column properties

I have a list containing values and I want to assign it to the column properties of a table in spotfire. I am currently using a for loop to do it. Is there a better approach to this, like assigning the entire list in one go?
As mentioned previously I am doing it currently using a for loop which can be seen below:
high=c(5,2,10)
low=c(3,1,0)
for(col in 1:ncol(temp)){
attributes(temp[,col])$SpotfireColumnMetaData$limits.whatif.upper=(high[col])[1]
attributes(temp[,col])$SpotfireColumnMetaData$limits.whatif.lower=(low[col)[1]
}
}
I have also tried just to do
attributes(temp2)$SpotfireColumnData$limits.whatif.upper=high
but that didnt seem to work.
So I want the column for limits.whatif.upper to be 5 for the first row, 2 for the second, and 10 for the third. As I said this code works, but I want to see if there is a faster way of doing it, since it seems that accessing the column property every time and changing it slows down the code a lot.The columns properties already exist so I am not creating new ones with this code.
It seems that python works faster than R with column properties. So if you need to do it faster, it may be better just to transfer the data over to python and do it from there. I dont have as much expierence in R, so it may just be poorly written R code as well.

Removing columns from an index request in a data frame

Hi I currently have the code:
matrixed.data <- data.matrix(df[1:row.dim,7:col.dim])
Where the row.dim and col.dim are variables for the size of the whole frame. I would like to remove the column "df$WEATHER" that is included in the col.dim selection but don't know how to word it. I have tried adding - df$WEATHER and !df$WEATHER inside the bracket but fear I'm misinterpreting the scope of these commands.
Is it possible to do this without creating a new col.dim variable; I'm trying to keep the code as limitless as possible as the data frame may increase in size in the future.
Thank you digEmAll! I thought it would be reasonably simple I'm just a bit too green at R to think of something like that. For others what worked for me was:
(df[1:row.dim, setdiff(7:col.dim,which(names(df) == "WEATHER"))])

filter by variable value in report block

I could find no relevant answers in either StackOverflow or google. Perhaps one of you has the answer. This is a continuation from a previous question...
In Business Objects Webi, I have two variables. One dimension, one measure. My goal is to create a simple pie chart.
Here's the dimension variable titled "EWFMCodeSelect":
`=If([Code]InList("BRK1"; "BRK2"; "BRK3" )) Then"BREAK"
ElseIf([Code]InList("TEAM"; "MTG"; "MTNG"; "PROJ"; "TRNG";"WCGB")) Then "DISC"
ElseIf([Code]InList("LUNCH")) Then "LUNCH"
ElseIf([Code]InList("LATE";"NOSHOW";"UNPAID";"UPVAC")) Then "MISS"
ElseIf([Code]InList("COACH";"VTO")) Then "NEUTR"
ElseIf([Code]InList("VAC";"LOA";"SICKUP";"SICKPL")) Then "NODISC"
ElseIf([Code]InList("PREP")) Then "OTHER"
ElseIf([Code]InList("OVER")) Then "OVER"
Else("SHIFT")`
This is the measure variable titled EWFMPieChart(%):
=[TimeDiff (ToInt)]
/ NoFilter(( Sum([TimeDiff (ToInt)]
ForAll([EWFMCodeSelect])
Where ([EWFMCodeSelect] = "SHIFT")))ForEach())
The previous advice I received was to filter the value "SHIFT" from the report block. I thought this would be a simple affair but it's proving more difficult than anticipated. I tried creating a Report Block filter in the Analysis tab "EWFMCodeSelect Not Equal To SHIFT"
"EWFMCodeSelect Not In List > SHIFT"
but only ended up with a single row, the dimension field empty, the measure field showing #MULTIVALUE. I tried a variety of other combinations but all had the same effect.
I tried a Column filter:
=[EWFMCodeSelect] Where ([EWFMCodeSelect] <> "SHIFT")
but ended up with a single row, the dimension field showing: "BREAKDISCLUNCH..." as the value and the measure, again, showing #MULTIVALUE.
I'm missing some important clue here. Can anyone educate me either why this approach is incorrect and maybe supply me with a direction to achieve my goal?
Thanks,
mfc
I don't have the correct answer but I did solve the problem by cleaning up all of the TEST variables, deleting all unused and unnecessary errata that collected up to this point and re-running the report as a scheduled item. I also cleared the browser cache (never bad advice).
After re-opening the report, I was able to filter the report block without issue.
I guess the answer is "When in doubt and receiving undocumented results, clean up your work-space and try again".

Google Spreadsheet IF and AND

im trying to find an easy formula to do the following:
=IF(AND(H6="OK";H7="OK";H8="OK";H9="OK";H10="OK";H11="OK";);"OK";"X")
This actually works. But I want to apply to a range of cells within a column (H6:H11) instead of having to create a rule for each and every one of them... But trying as a range:
=IF(AND(H6:H11="OK";);"OK";"X")
Does not work.
Any insights?
Thanks.
=ArrayFormula(IF(AND(H6:H11="OK");"OK";"X"))
also works
arrayformulas work the same way they do in excel... they just need an ArrayFormula() around to work (will be automatically set when pressing Ctrl+Alt+Return like in excel)
In google sheets the formula is:
=ArrayFormula(IF(SUM(IF(H6:H11="OK";1;0))=6;"OK";"X"))
in excel:
=IF(SUM(IF(H6:H11="OK";1;0))=6;"OK";"X")
And confirm with Ctrl-Shift-Enter
This basically counts the number of times the said range is = to the criteria and compares it to the number it should be. So if the range is increased then increase the number 6 to accommodate.

R studio wont recognize my variables? any ideas why?

So I imported the file and saved it as Purity and its clearly imported. I tried t-test but it doesn't recognize my variables. I tried using the names function to retrieve the variable names and its exactly what I'm entering, V1 and V2. I also tried with Lab-1 and Lab-2. I also tried just using dataset=Purity, all to no avail.
I took a screenshot so as to show code and that data is in the studio, can anyone tell me why this is not working?
apologies if this is painfully obvious I was only introduced to R for stats last week and am still a beginner, also don't have much experience with programming in general. I have looked at other similar problems but just cant see why mine aren't being recognised and others are.
You've got 2 issues here:
1). You don't show how you imported the dataset but you need to either remove the first row or (better) name the columns correctly. I'm assuming you imported the data with read.table(). If so, then include the argument header = TRUE when you import the data.
2). You need to tell R where you want it to get Lab-1 and Lab-2 from.
with(Purity, t.test(Lab-1, Lab-2, paired = TRUE))
r is case sensitive. It looks like your script is using a lowercase 'v" when its an upper case "V" in your variable names.
The problem is in the way you have named your variable. r doesn't recognise the hyphen (-) as a legitimate part of a variable name. Try using underscore (_) instead.

Resources