PHPSpreadsheet 1.15.0, access cell by name - phpspreadsheet

I have an Excel "Template" with some named cells as "student" for example, which is the cell coordinates B2
I used to use PHPSpreadsheet and access some cells by: $worksheet->getCell('student');
It worked until the last 1.15.0 version, which returns me this error: "Fatal error: Uncaught Error: Call to a member function getCell() on null"
In my Excel file this named cell is "=Feuil1!$B$5", but if I try to manually change it to "=Feuil1!B5" I have some stranges behaviours, the named cell place change for C5, or B4, etc...
I really need to access cells by name by I don't know how to do this with the 1.15.0 version of PHPSpreadSheet...
Thanks!

Related

How to give a cell containing with 'ISREF' a default value in Google Sheets

I am trying to use a formula that uses INDEX function. In order to generalize for all the lines that sometimes may contain information from another sheet and sometimes they may not.
That's why I get an ISREF error within the cells because the corresponding cells in the other sheet can't be referenced.
I want to display a default value instead of the ISREF error message. I tried using ISREF function itself within an IF condition but it doesn't work on the same cell. It only references another cell because it is a cell checking function and it doesn't check the output of a formula.
I tried also ISERROR function but it didn't work also. Here's a snippet of the formula that I am putting within my cell:'
INDEX(Plagesuivi; $Q203; 9)
Plagesuivi is a named range
$Q203 contains the row number (that I fetch dynamically and correctly)
9 is the column number
P.S. The indexing is working fine with cells that do appear is the named range: Plagesuivi
I would go with iferror() like this:
=iferror(INDEX(Plagesuivi;$Q203;9);0)
Or replace the 0 with ""
After trial and error the best way to avoid all sorts of errors is:
= IF($Q203=""; 0; IFERROR(INDEX(Plagesuivi; $Q203; 9); 0))
IFERROR checks for all sorts of unpredictable errrors it is a safe-guard against unpredicted cases where it takes 0 by default.
IF in the second case checks whether the referencing content of Q203 is empty or not, in case it is empty the cell takes 0 by default else it gets the output of the false case formula.

#REF! error Array result was not expanded because it would overwrite data in C33

I have several cells with #REF! but most do not. I cannot figure out why those few keep getting the #REF! error. Error states: Array result was not expanded because it would overwrite data in C33
My formula is: =iferror(query('Proposal Legend'!$A$2:$B$1101,"select A where B = '"&B32&"'",0),"")
It appears as though you have content below cell C33 that is interfering with the returned results of your QUERY function. See image below:
We are querying all the items in Column A that have a YES value in column B. Similar to your formula.
However, if I enter a value in cell D3 I get an error due to the fact that my above formula wants to return 3 results, but in the 3rd cell of results I already have information.

How to identify EXACTLY the error type in Google Sheets?

I have a spreadsheet which I need to import several data from other spreadsheets, So I have =importrange(<theOtherFile>,<cell>) in different places. But I have to go, one by one allowing access the first time my file is created.
What I want is to have an a different sheet a list with all the document references I link in the document. Over there, there is a list of all documents including Google Docs and Google Presentations. Then a script creates a =importrange() for each of them so I can, in one shot, press "Allow Access" once for each file (and the needed values pop up in the other places).
The problem is that in this huge list of importranges, I cannot tell apart #REF errors because I still don't have permission to collect data from the file or because the file is not a spreadsheet at all ("Spreadsheet cannot be found." error).
So, my question is: can I, beforehand, tell apart Google Sheets from other types of files so my script doesn't try to import them? If not; Can I somehow interact with the error message of a #REF error (this way I could write a formula that cleans the cell if the importrange() failed because the file is not a spreadsheet at all)?
=ERROR.TYPE(A1)
#NULL! 1
#DIV/0! 2
#VALUE! 3
#REF! 4
#NAME? 5
#NUM! 6
#N/A 7
#ERROR! 8
(no error) #N/A
if a cell has no error, the ERROR.TYPE gives an error. Use:
=IFERROR(ERROR.TYPE(B11);"No error")
Google Sheets offers only two functions to nullify the errors:
IFERROR - Returns the first argument if it is not an error value, otherwise returns the second argument if present, or a blank if the second argument is absent.
IFNA - Returns the first argument if it is not an #N/A error value, otherwise returns the second argument if present, or a blank if the second argument is absent.
to analyze the error you can use:
ERROR.TYPE - Returns a number corresponding to the error value in a different cell.
ISREF - Checks whether a value is a valid cell reference.
ISNA - Checks whether a value is the error #N/A.
ISERR - Checks whether a value is an error other than #N/A
ISERROR - Checks whether a value is an error.

How can I use conditional formatting to compare against a dynamic worksheet?

I am trying to use conditional formatting to compare the value of one cell against another in a dynamically referenced worksheet while using a dynamic cell reference and highlight the cell whenever the values do not match.
I have created a master sheet containing a cell with the name of the worksheet I wish to reference. This cell will be updated periodically with the name of the relevant worksheet. I am able to write a formula that correctly returns the value I wish to compare, but when I enter this expression in the conditional format rule (format cells if is not equal to) I am given a red outline with the message "Invalid formula".
I have tried various combinations such as using a custom formula and using (current cell = (formula here)) and while I am not given an error, it still does not work as intended.
I am comparing the value of cell C2 in worksheet 4719 to cell C2 in worksheet 4717. A cell in a worksheet called Mastersheet contains the entry "4717" in B1, and this is the cell that will be periodically changed to something like 4717 for example.
The formula that is able to successfully return the value I am after is =indirect(Mastersheet!B1&"!"&"C2") but I was only able to accomplish this by putting the "C2" reference in quotation marks, which is not dynamic and thus would have to be manually changed to work for any of the other values in column C.
I expect cell C1 in worksheet 4719 to turn green as the value there is different from cell C1 in worksheet 4718.
I made a publicly viewable copy of my Google sheet if my explanation does not make enough sense https://docs.google.com/spreadsheets/d/1s0oaGas46akmGV7hapnDOdhndcWudyq239kmCrLnt3U/edit?usp=sharing
try it like this:
=INDIRECT(Mastersheet!$B$1&"!"&ADDRESS(ROW(C2), COLUMN(C2), 4))
this can be used in Conditional formatting, however, referenced sheet cant be fully active so:
=INDIRECT(INDIRECT("Mastersheet!B1")&"!"&ADDRESS(ROW(C2),COLUMN(C2),4))
this can be further moded so the B1 would be dynamic too:
=INDIRECT(INDIRECT("Mastersheet!"&ADDRESS(ROW(B1),COLUMN(B1)))&"!"&
ADDRESS(ROW(C2),COLUMN(C2),4))=19

How to reference a different spreadsheet in HLOOKUP?

I try to reference another spreadsheet in the HLOOKUP formula but fail. I'm doing this like:
=HLOOKUP(A2,"https://docs.google.com/spreadsheets/d/1qOzV/","report!A2:B2",2,0)
where http... is the URL of another spreadsheet, report!... is the name of the tab in another spreadsheet and the data range.
This kind of referencing of another spreadsheet's URL works with =importrange("https://docs.google.com/spreadsheets/d/1qOzV/","report!A2:B2"), as I realized from different examples.
But with HLOOKUP while doing so I get an error:
Wrong number of arguments to HLOOKUP. Expected between 3 and 4 arguments, but got 5 arguments.
It seems, that the spreadsheet URL is counted as separate parameter.
How do I correctly reference the URL, the sheet name and the data range?
PS: I tried to chain HLOOKUP and importrange, as mentioned in https://stackoverflow.com/a/39305031/1992004 - but fail on it, got just #REF.
My formula was
=HLOOKUP(A2,IMPORTRANGE("https://docs.google.com/spreadsheets/d/1qOzV"; "report!$A$2:$B$2"),2,0)
you are searching the content of cell A2 against imported range A2:B2 and if the match is found you returning the 1st row (of the whole dataset) of imported range after match eg. that's cell B2 of report!$A$2:$B$2. in other words range A2:B2 is one row so you cant return 2nd row from the one-row matrix, therefore valid formula is:
=HLOOKUP(A2,IMPORTRANGE("1I69LQ37hA5NjjJmuwmWkrDI_daiU_cnYDrUBpMm","report!$A$2:$B$2"),1,0)

Resources