LENB function
The LENB function in Jspreadsheet Formulas Pro is a tool that gives you the total number of bytes in a specific text string. It's useful when you're dealing with data that needs byte-level analysis. For instance, if you input LENB("Hello") into a cell, you'll get the result 5, as 'Hello' consists of 5 bytes. This function can be particularly useful when you're dealing with large amounts of text and need a quick way to analyze the data size.
Documentation
Returns the number of bytes in a text string.
Category
Text
Syntax
LENB(text)
| Parameter | Description | 
|---|---|
text | 
The text string whose byte length you want to find. | 
Behavior
The LENB function is used to return the length of a text string as the number of bytes. This function can be extremely useful when dealing with texts in different languages where a single character may take more than one byte. Here are some common behaviors:
- Empty Cells: If the 
LENBfunction is used on an empty cell, it will return 0. - Text: If used on a cell containing text, it returns the number of bytes used to represent the characters.
 - Numbers: If used on a cell containing a number, it will consider the number as a text string and return the number of bytes used to represent it.
 - Booleans: If used on a cell containing a boolean value, it will consider the boolean as a text string and return the number of bytes used to represent it.
 - Errors: If used on a cell containing an error, it will return that error.
 - Arrays: 
LENBdoes not operate on arrays. 
Common Errors
| Error | Description | 
|---|---|
| #VALUE! | This error occurs when the argument is an unsupported type such as an array or a range of cells. | 
| #REF! | This error occurs when the cell reference is not valid. | 
Best practices
- Be aware that
 LENBcounts bytes, not characters. This can lead to different results for languages where a single character may be represented by more than one byte.- Always check for leading or trailing spaces in your text strings that might be affecting the
 LENBresult.- Use the
 TRIMfunction in combination withLENBto remove unnecessary spaces.- Be mindful of non-printable characters which might be included in your text string and affect the byte count.
 
Usage
A few examples using the LENB function.
LENB('apple') returns 5  
LENB('banana') returns 6  
LENB('cherry') returns 6 
LENB("ありがとう") returns 15
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('OWI0NGRhZTUyNDQzNjg4ZGY3NzcxMjFjZDg0YzY4MGQ0NGVmMzZiOTYxY2NlYjQ5M2E1YTc0MTJlNDQ5ZWJjZGI3NmVmMTEwZTE5M2E0NTc5ZTkzMzBhNjEwNzYwMDM3MGE4ZjZhZWU2NzJiZTcxNWFkYWEyOGVmOTBkN2Y0NTAsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16TTNOemd4TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
  worksheets: [{
    data: [
    [
        "Product Name",
        "Byte Count"
    ],
    [
        "apple",
        "=LENB(A2)"
    ],
    [
        "banana",
        "=LENB(A3)"
    ],
    [
        "cherry",
        "=LENB(A4)"
    ],
    [
        "orange",
        "=LENB(A5)"
    ]
]
  }]
});
</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('OWI0NGRhZTUyNDQzNjg4ZGY3NzcxMjFjZDg0YzY4MGQ0NGVmMzZiOTYxY2NlYjQ5M2E1YTc0MTJlNDQ5ZWJjZGI3NmVmMTEwZTE5M2E0NTc5ZTkzMzBhNjEwNzYwMDM3MGE4ZjZhZWU2NzJiZTcxNWFkYWEyOGVmOTBkN2Y0NTAsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16TTNOemd4TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default function App() {
    // Spreadsheet array of worksheets
    const spreadsheet = useRef();
    // Worksheet data
    const data = [
    [
        "Product Name",
        "Byte Count"
    ],
    [
        "apple",
        "=LENB(A2)"
    ],
    [
        "banana",
        "=LENB(A3)"
    ],
    [
        "cherry",
        "=LENB(A4)"
    ],
    [
        "orange",
        "=LENB(A5)"
    ]
];
    // 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('OWI0NGRhZTUyNDQzNjg4ZGY3NzcxMjFjZDg0YzY4MGQ0NGVmMzZiOTYxY2NlYjQ5M2E1YTc0MTJlNDQ5ZWJjZGI3NmVmMTEwZTE5M2E0NTc5ZTkzMzBhNjEwNzYwMDM3MGE4ZjZhZWU2NzJiZTcxNWFkYWEyOGVmOTBkN2Y0NTAsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16TTNOemd4TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default {
    components: {
        Spreadsheet,
        Worksheet,
    },
    data() {
        // Worksheet data
        const data = [
    [
        "Product Name",
        "Byte Count"
    ],
    [
        "apple",
        "=LENB(A2)"
    ],
    [
        "banana",
        "=LENB(A3)"
    ],
    [
        "cherry",
        "=LENB(A4)"
    ],
    [
        "orange",
        "=LENB(A5)"
    ]
]
        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('OWI0NGRhZTUyNDQzNjg4ZGY3NzcxMjFjZDg0YzY4MGQ0NGVmMzZiOTYxY2NlYjQ5M2E1YTc0MTJlNDQ5ZWJjZGI3NmVmMTEwZTE5M2E0NTc5ZTkzMzBhNjEwNzYwMDM3MGE4ZjZhZWU2NzJiZTcxNWFkYWEyOGVmOTBkN2Y0NTAsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16TTNOemd4TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// 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 Name",
        "Byte Count"
    ],
    [
        "apple",
        "=LENB(A2)"
    ],
    [
        "banana",
        "=LENB(A3)"
    ],
    [
        "cherry",
        "=LENB(A4)"
    ],
    [
        "orange",
        "=LENB(A5)"
    ]
]
            }]
        });
    }
}