THISROWCELL function
PRO
The THISROWCELL
function in Jspreadsheet Formulas Pro is a handy tool for accessing data within a particular cell on the same row. You simply need to provide the index of the column you're interested in. For example, if your function is in row 3 and you wish to access data in column 2 of the same row, THISROWCELL
allows you to do that. This function makes it easy to reference and retrieve data from other cells within the same row.
Documentation
The THISROWCELL function retrieves the value of a cell located in the same row as the calling cell, specified by the column index.
Category
Jspreadsheet
Syntax
THISROWCELL(column_index)
Parameter | Description |
---|---|
column_index |
The numeric index of the column (1 = first column, 2 = second column, etc.) to retrieve the value from in the current row. |
Behavior
The THISROWCELL
function is used to retrieve the value from a cell in the same row, based on the specified column index.
- For empty cells: If the cell in the current row of the specified column is empty, the function return an empty value.
- For text: The function returns the text present in the cell in the current row of the specified column.
- For booleans: The function returns the boolean value (TRUE or FALSE) present in the cell in the current row of the specified column.
- For errors: If the referenced cell contains an error, the function returns the same error.
Common Errors
Error Name | Description |
---|---|
#VALUE! | Occurs if the function is used outside a valid table row context. |
Best Practices
- Always ensure that the specified column exists to avoid a #REF! error.
- Use
THISROWCELL
function only within the context of a table or a similar data structure where the concept of "current row" makes sense.- Avoid using
THISROWCELL
function to reference cells that might contain errors. Instead, handle those errors at the source whenever possible.
Usage
A few examples using the THISROWCELL function.
THISROWCELL(1)
Retrieves the value from the first column of the current row.
THISROWCELL(3)
If used in row 5, it retrieves the value from column 3 of row 5.
IF(THISROWCELL(2)="USA","Domestic","International")
Checks if column 2 of the current row is "USA" and returns "Domestic" or "International".
THISROWCELL(4)*2
If column 4 contains a number, doubles its value in the formula result.
Interactive Spreadsheet Demo
<html>
<script src="https://jspreadsheet.com/v11/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />
<link rel="stylesheet" href="https://jspreadsheet.com/v11/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/formula-pro/dist/index.min.js"></script>
<div id="spreadsheet"></div>
<script>
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('NWU3NTg0MmM3OTBhNmExYzExNTMxZjM0MWY4ZDliNGZmYmVhNTQ5ZDdhNjM5NjVhNzMzYTkwNWIyMWIxZGRjOGExZDUyNjJmMTkzODAwZjEyMjZkMDFjMmRmNDRiY2ZmZWZlYzk4MWZkODVjNTllMWFkYWYxYzQ5YWExZWJmYzYsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXhORFEyTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// Set the extensions
jspreadsheet.setExtensions({ formula });
// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
worksheets: [{
data: [
[
"Product",
"Price",
"Tax Rate",
"Tax Amount"
],
[
"Laptop",
999.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
],
[
"Mouse",
29.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
],
[
"Keyboard",
79.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
]
]
}]
});
</script>
</html>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/react";
import formula from "@jspreadsheet/formula-pro";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
// Set license
jspreadsheet.setLicense('NWU3NTg0MmM3OTBhNmExYzExNTMxZjM0MWY4ZDliNGZmYmVhNTQ5ZDdhNjM5NjVhNzMzYTkwNWIyMWIxZGRjOGExZDUyNjJmMTkzODAwZjEyMjZkMDFjMmRmNDRiY2ZmZWZlYzk4MWZkODVjNTllMWFkYWYxYzQ5YWExZWJmYzYsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXhORFEyTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default function App() {
// Spreadsheet array of worksheets
const spreadsheet = useRef();
// Worksheet data
const data = [
[
"Product",
"Price",
"Tax Rate",
"Tax Amount"
],
[
"Laptop",
999.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
],
[
"Mouse",
29.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
],
[
"Keyboard",
79.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
]
];
// Render component
return (
<Spreadsheet ref={spreadsheet}>
<Worksheet data={data} />
</Spreadsheet>
);
}
<template>
<Spreadsheet ref="spreadsheet">
<Worksheet :data="data" />
</Spreadsheet>
</template>
<script>
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/vue";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
import formula from "@jspreadsheet/formula-pro";
// Set license
jspreadsheet.setLicense('NWU3NTg0MmM3OTBhNmExYzExNTMxZjM0MWY4ZDliNGZmYmVhNTQ5ZDdhNjM5NjVhNzMzYTkwNWIyMWIxZGRjOGExZDUyNjJmMTkzODAwZjEyMjZkMDFjMmRmNDRiY2ZmZWZlYzk4MWZkODVjNTllMWFkYWYxYzQ5YWExZWJmYzYsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXhORFEyTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default {
components: {
Spreadsheet,
Worksheet,
},
data() {
// Worksheet data
const data = [
[
"Product",
"Price",
"Tax Rate",
"Tax Amount"
],
[
"Laptop",
999.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
],
[
"Mouse",
29.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
],
[
"Keyboard",
79.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
]
]
return {
data
};
}
}
</script>
import { Component, ViewChild, ElementRef } from "@angular/core";
import jspreadsheet from "jspreadsheet";
import * as formula from "@jspreadsheet/formula-pro";
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('NWU3NTg0MmM3OTBhNmExYzExNTMxZjM0MWY4ZDliNGZmYmVhNTQ5ZDdhNjM5NjVhNzMzYTkwNWIyMWIxZGRjOGExZDUyNjJmMTkzODAwZjEyMjZkMDFjMmRmNDRiY2ZmZWZlYzk4MWZkODVjNTllMWFkYWYxYzQ5YWExZWJmYzYsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXhORFEyTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// Set the extensions
jspreadsheet.setExtensions({ formula });
@Component({
standalone: true,
selector: "app-root",
template: `<div #spreadsheet></div>`
})
export class AppComponent {
@ViewChild("spreadsheet") spreadsheet: ElementRef;
// Worksheets
worksheets: jspreadsheet.worksheetInstance[];
// Create a new data grid
ngAfterViewInit() {
// Create spreadsheet
this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
worksheets: [{
data: [
[
"Product",
"Price",
"Tax Rate",
"Tax Amount"
],
[
"Laptop",
999.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
],
[
"Mouse",
29.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
],
[
"Keyboard",
79.99,
0.08,
"=THISROWCELL(2)*THISROWCELL(3)"
]
]
}]
});
}
}