phpspreadsheet retrieve cell value as unformatted text - phpspreadsheet

Collect necessary rows into array ->toArray()
unseccessfully try to get unformatted text value from cell. Made the following:
$reader->setReadDataOnly(true);
and
->rangeToArray(
'A1:Q11', // The worksheet range that we want to retrieve
'', // Value that should be returned for empty cells
FALSE, // Should formulas be calculated (the equivalent of getCalculatedValue() for each cell)
FALSE, // Should values be formatted (the equivalent of getFormattedValue() for each cell)
TRUE // Should the array be indexed by cell row and cell column
);
I get 777,7 as 777.7, but 777,77 as 777,77

Related

google sheet add button to insert new row that has formula

This is the simplified version of my data. I want to place a button at the bottom of the grey area, so that upon clicking, a new row is inserted above the bottom. the new row must have the formula as the rows before it.
my real formulas are very complicated so I cant use arrayFormula to fulfill the data in new rows.
this a link to my spreadsheet.
You can refer to this sample code that uses a custom menu to insert new row with formula based on the previous row.
Code:
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
ui.createMenu('Custom Menu')
.addItem('Insert New Row', 'insertRow')
.addToUi();
}
function insertRow() {
var sheet = SpreadsheetApp.getActiveSheet();
var lastRow = sheet.getLastRow();
var lastCol = sheet.getLastColumn();
//Exit function if current active sheet is not Sheet1
if(sheet.getName() != "Sheet1"){
return;
}
//insert new row
sheet.insertRowAfter(lastRow);
sheet.getRange(lastRow,2,1,3).copyTo(sheet.getRange(lastRow+1,2));
}
What it does?
Get the last row and the last column that has content in the active sheet using getLastRow() and getLastColumn()
Insert a new row after the last row that has content using insertRowAfter(afterPosition)
Get the range of the last row that has content using getRange(row, column, numRows, numColumns)
Where:
row = your last row that has content
column = column index where you want to start (in the sample sheet it is in column B/ index 2)
numRows = should be 1 (we only want to copy the current last row that has content)
numCols = how many columns to select. In the sample sheet there are 3 columns (column B-D)
Use copyTo(destination) to copy both values and formatting of the range selected in step 3 and paste it in the newly added row. Destination range should be the top-left cell. Since we want to copy it to the new row.I used getRange(last row +1, 2)
Output:
Note:
If you want to use button placed below the grey row, just use insertRow when you assign a script in your button
Please make sure that the last row with content is the row that has formula.
If you want to use the function on a specified list of sheets, you can add this in the sample code. This will exit the function if the current active sheet name is not included in the valid sheets listed
var validSheets = ["Sheet1", "Sheet2"];
if(!validSheets.includes(sheet.getName())){
return;
}
Remove the last comment ... then click on the new menu : this script will add a new line in the active sheet
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('>> Action <<')
.addItem('Copy last row (formulas only)', 'copyLastRow')
.addToUi();
}
function copyLastRow() {
var sh=SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
var rng=sh.getRange(sh.getLastRow(),1,1,sh.getLastColumn())
rng.copyTo(sh.getRange(sh.getLastRow()+1,1,1,sh.getLastColumn()), SpreadsheetApp.CopyPasteType.PASTE_FORMULA, false)
}

Google Sheet cell value does not match

I am trying to compare to cell in google sheet. Both the cell contains Value "Saturday".
Cell A1 = TEXT(WEEKDAY(N1),"dddd") value is "Saturday"
Cell A2 = =B2 value is "Saturday"
but when I compare both =IF(A1=A2,"TRUE","FALSE") Result is FALSE. I tried changing both cell to plain text but it did not work. Any solution?

Check if each cell range in a row contains the same value

How can I check in Google Sheets if each cell in a range e.g. B2:G2 contains a word e.g. holiday?
=ARRAYFORMULA(IF(IFERROR(REGEXEXTRACT(B2:G2, "holiday"))<>"", TRUE))
=ARRAYFORMULA(IF(SUM(IF(IFERROR(REGEXEXTRACT(B3:G3, "holiday"))<>"", 1))=6, TRUE))

Combine data from multiple cell in one cell with text

I have a row A with 200 text entries.
A1 = "A1value"
A2 = "A2value"
A3 = "A3value"
...
I want to dynamicaly display in a single cell (text format) : ga=A1value,ga=A2value,ga=A3value, [...] ga=A200value etc...
use join function:
=JOIN(",ga=", A1:A3)
for some regions semicolon is used:
=JOIN(",ga="; A1:A3)
next step: add first "ga=" manually:
="ga="&JOIN(",ga=", A1:A3)

Google spreadsheet cell reference from value of another cell

This is the scenario:
In cell A1 I have value "12".
In cell B1 I enter value "1".
In cell C1 I want to have value of Column "A" and row defined in cell B1.
How can I display the value "12"?
=INDIRECT("A"&B1)
Help page for INDIRECT function: https://support.google.com/drive/answer/3093377?hl=en-GB

Resources