Socket
Book a DemoInstallSign in
Socket

aspose.cells.js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aspose.cells.js

Aspose.Cells for JavaScript via C++ is a high-performance, feature-rich library for manipulating and converting Excel (XLS, XLSX, XLSB), ODS, CSV, and HTML files. It provides a comprehensive set of features for creating, editing, converting, and rendering

25.8.0
latest
npmnpm
Version published
Maintainers
1
Created
Source

aspose.cells.js

Aspose.Cells for JavaScript via C++ is a high-performance, feature-rich library for manipulating and converting spreadsheet files, including Excel (XLS, XLSX, XLSB, XLSM), ODS, CSV, and HTML formats. It provides a comprehensive set of features for creating, editing, converting, and rendering spreadsheets in both browser and Node.js environments. With full support for all major Excel formats, Aspose.Cells for JavaScript via C++ ensures maximum compatibility and flexibility across diverse use cases.

Built with WebAssembly to unlock near-native performance directly in the browser, Aspose.Cells for JavaScript via C++ enables fast and efficient spreadsheet processing without the need for a server. Its lightweight runtime footprint makes it perfect for serverless web applications that require advanced Excel functionality. Whether you're building dashboards, data processing pipelines, or document generation tools, Aspose.Cells for JavaScript via C++ offers a complete, reliable, and high-performance solution that works seamlessly across web, server-side, and hybrid environments.

Key features

  • File Creation and Editing: Create new spreadsheets from scratch or edit existing ones with ease. This includes adding or modifying data, formatting cells, managing worksheets, and more.
  • Data Processing: Perform complex data manipulations such as sorting, filtering, and validation. The library also supports advanced formulas and functions to facilitate data analysis and calculations.
  • File Conversion: Convert Excel files to various formats such as PDF, HTML, ODS, and image formats like PNG and JPEG. This feature is useful for sharing and distributing spreadsheet data in different formats.
  • Chart and Graphics: Create and customize a wide range of charts and graphics to visually represent data. The library supports bar charts, line charts, pie charts, and many more, along with customization options for design and layout.
  • Rendering and Printing: Render Excel sheets to high-fidelity images and PDFs, ensuring that the visual representation is accurate. The library also provides options for printing spreadsheets with precise control over page layout and formatting.
  • Advanced Protection and Security: Protect spreadsheets with passwords, encrypt files, and manage access permissions to ensure data security and integrity.
  • Performance and Scalability: Designed to handle large datasets and complex spreadsheets efficiently, Aspose.Cells for JavaScript via C++ ensures high performance and scalability for enterprise-level applications.

Read & Write Excel Files

  • Microsoft Excel: XLS, XLSX, XLSB, XLTX, XLTM, XLSM, XML
  • OpenOffice: ODS
  • Text: CSV, Tab-Delimited, TXT, JSON
  • Web: HTML, MHTML

Save Excel Files As

  • Fixed Layout: PDF, XPS
  • Images: JPEG, PNG, BMP, SVG, TIFF, GIF, EMF
  • Text: CSV, Tab-Delimited, JSON, SQL, XML

Browser and Node.js Support

  • Fully compatible with modern browsers (Chrome, Firefox, Edge, Safari) and Node.js runtimes.
  • Ensures consistent behavior across both client-side and server-side applications for seamless integration and execution.

Getting Started

Create a XLSX File in html

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
    </body>

    <script src="aspose.cells.js.min.js"></script>
    <script type="text/javascript">
        const { Workbook, FileFormatType, SaveFormat } = AsposeCells;
        AsposeCells.onReady().then(() => {
            var workbook = new Workbook(FileFormatType.Xlsx);
            workbook.worksheets.get(0).cells.get("A1").putValue("Hello World");
            const outputData = workbook.save(SaveFormat.Xlsx);
            const blob = new Blob([outputData]);
            const downloadLink = document.createElement('a');
            downloadLink.href = URL.createObjectURL(blob);
            downloadLink.textContent = 'Download';
            downloadLink.download = "hello-world.xlsx";
            downloadLink.style.display = 'block';
            document.body.append(downloadLink);
        });
    </script>
</html>

License

You need to use encrypt_lic.html in a http server to get the encrypted license file (aspose.cells.enc) in order to run in full-featured mode. To run the http server:

cd node_modules/aspose.cells.js
python -m http.server 8080

Convert Excel File to PDF in html

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <input type="file" id="fileInput" />
        <button id="toPdf">Save to Pdf</button>
        <a id="downloadLink" style="display: none;">Download</a>
    </body>

    <script src="aspose.cells.js.min.js"></script>
    <script type="text/javascript">
        const { Workbook, SaveFormat } = AsposeCells;
        AsposeCells.onReady({
                license: "/lic/aspose.cells.enc",
                fontPath: "/fonts/",
                fontList: [
                    "arial.ttf",
                    "NotoSansSC-Regular.ttf"
                ]
            }).then(() => {
        });

        async function openSave(saveFormat, extension) {
            const fileInput = document.getElementById('fileInput');
            if (!fileInput.files.length) {
                alert('Please select an Excel file.');
                return;
            }

            const file = fileInput.files[0];
            const arrayBuffer = await file.arrayBuffer();
            var workbook = new Workbook(new Uint8Array(arrayBuffer));
            const outputData = workbook.save(saveFormat);

            const blob = new Blob([outputData]);
            const downloadLink = document.getElementById('downloadLink');
            downloadLink.href = URL.createObjectURL(blob);
            downloadLink.download = 'output.' + extension;
            downloadLink.style.display = 'block';
        }

        document.getElementById('toPdf').addEventListener('click', async () => {
            await openSave(SaveFormat.Pdf, "pdf");
        });
    </script>
</html>

Format Excel Cells in html

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
    </body>

    <script src="aspose.cells.js.min.js"></script>
    <script type="text/javascript">
        const { Workbook, Color, SaveFormat } = AsposeCells;
        AsposeCells.onReady().then(() => {
            var workbook = new Workbook();
            var style = workbook.createStyle();
            style.font.setName("Times New Roman");
            style.font.color = Color.Blue;
            for (var i = 0; i < 10; i++) {
                var cell = workbook.worksheets.get(0).cells.get(0, i);
                cell.putValue(i);
                cell.setStyle(style);
            }
            const outputData = workbook.save(SaveFormat.Xlsx);
            const blob = new Blob([outputData]);
            const downloadLink = document.createElement('a');
            downloadLink.href = URL.createObjectURL(blob);
            downloadLink.textContent = 'Download';
            downloadLink.download = "style-example.xlsx";
            downloadLink.style.display = 'block';
            document.body.append(downloadLink);
        });
    </script>
</html>

Convert XLSX to Pdf in Node.js

const fs = require("fs");
const { AsposeCells } = require("aspose.cells.js");
const { Workbook, SaveFormat } = AsposeCells;

AsposeCells.onReady({
        license: "aspose.cells.enc",
        fontPath: "./fonts/",
        fontList: [
            "arial.ttf",
            "NotoSansSC-Regular.ttf"
        ]
    }).then(() => {
    const fileBuffer = fs.readFileSync("example.xlsx");
    var workbook = new Workbook(new Uint8Array(fileBuffer));
    const outputData = workbook.save(SaveFormat.Pdf);
    fs.writeFileSync("output.pdf", outputData);
});

Create a XLSX file using ES6 in Node.js

import fs from 'fs';
import { AsposeCells } from 'aspose.cells.js';
const { Workbook, FileFormatType, SaveFormat } = AsposeCells;

AsposeCells.onReady({
        license: "aspose.cells.enc",
        fontPath: "./fonts/",
        fontList: [
            "arial.ttf",
            "NotoSansSC-Regular.ttf"
        ]
    }).then(() => {
    var workbook = new Workbook(FileFormatType.Xlsx);
    workbook.worksheets.get(0).cells.get("A1").putValue("Hello World");
    const outputData = workbook.save(SaveFormat.Xlsx);
    fs.writeFileSync("hello-es6.xlsx", outputData);
});

Note: Please save the above code as example.mjs file and run it using node example.mjs.

Calculate custom functions in html

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <button id="customfunction">Custom Function</button>
        <div id="log-container"></div>
    </body>

    <script src="aspose.cells.js.min.js"></script>
    <script type="text/javascript">
        const { Workbook, CalculationOptions, AbstractCalculationEngine } = AsposeCells;
        AsposeCells.onReady().then(() => {
            class CustomFunction extends AbstractCalculationEngine {
                constructor() {
                    super();
                }

                calculate(data) {
                    var functionName = data.functionName;
                    if (functionName == "myarrayfunch") {
                        var r = new Array();
                        r[0] = [1.0, 2.0, 3.0, 4.0, 5.0];
                        data.calculatedValue = r;
                        return;
                    }
                    else if (functionName == "myarrayfuncv") {
                        var r = new Array();
                        r[0] = [1.0];
                        r[1] = [2.0];
                        r[2] = [3.0];
                        r[3] = [4.0];
                        r[4] = [5.0];
                        data.calculatedValue = r;
                        return;
                    }
                    else if (functionName == "myrange") {
                        data.calculatedValue = data.worksheet.cells.createRange("A1", "F1");
                        return;
                    }
                    else if (functionName == "UDFTest") {
                        data.calculatedValue = data.getParamValue(0);
                    }
                }
            };
            
            async function calculateCustomFunction() {
                var wb = new Workbook();
                var sheet = wb.worksheets.get(0);
                var cells = sheet.cells;

                // Create table with data
                var range = cells.createRange("B3:D5");
                var arr = new Array();
                arr[0] = ["AccountNum", "UDF", "Normal"];
                arr[1] = ["Row01", "", ""];
                arr[2] = ["Row02", "", ""];

                range.value = arr;
                var firstRow = range.firstRow;
                var firstColumn = range.firstColumn;
                var endRow = firstRow + range.rowCount;
                var endColumn = firstColumn + range.columnCount;
                sheet.listObjects.add(firstRow, firstColumn, endRow, endColumn, true);

                // Populate formulas
                cells.get("C5").formula = "=UDFTest([@AccountNum])";
                cells.get("C4").formula = "=UDFTest([@AccountNum])"; // UDF formula

                cells.get("D5").formula = "=[@AccountNum]";
                cells.get("D4").formula = "=[@AccountNum]"; // Built-in formula comparison

                // Calculate workbook
                var opt = new CalculationOptions();
                var customFunction = new CustomFunction();
                opt.customEngine = customFunction;
                wb.calculateFormula(opt);

                addLog("Row01" == cells.get("C4").stringValue);
                addLog("Row02" == cells.get("C5").stringValue);
                addLog("Row01" == cells.get("D4").stringValue);
                addLog("Row02" == cells.get("D5").stringValue);

                var workbook = new Workbook();
                var worksheet = workbook.worksheets.get(0);

                // Get the cells collection in the sheet
                var cells = worksheet.cells;
                cells.get("A1").setArrayFormula("=myarrayfunch()", 1, 5);
                cells.get("A2").setArrayFormula("=myarrayfuncv()", 5, 1);
                cells.get("A7").setArrayFormula("=A1:E1*100", 1, 5);
                cells.get("A8").setFormula("=sum(myrange())", 100);

                var cf = new CustomFunction();
                var cOpt = new CalculationOptions();
                cOpt.customEngine = cf;
                workbook.calculateFormula(cOpt);
                for (var i = 0; i < 5; i++) {
                    addLog(i + 1.0 == cells.get(0, i).doubleValue);
                }
                for (var i = 1; i < 6; i++) {
                    addLog(i == cells.get(i, 0).doubleValue);
                }
                for (var i = 0; i < 5; i++) {
                    addLog(i * 100 + 100.0 == cells.get(6, i).doubleValue);
                }
                addLog(cells.get("A8").doubleValue == 15);
                addLog("calculate custom function done.");
            }

            document.getElementById('customfunction').addEventListener('click', async () => {
                document.getElementById('log-container').innerHTML = '';
                await calculateCustomFunction();
            });
        });

        function addLog(message) {
            const logContainer = document.getElementById('log-container');
            const messageSpan = document.createElement('span');
            messageSpan.textContent = message;
            logContainer.appendChild(messageSpan);
            logContainer.appendChild(document.createElement('br'))
            logContainer.scrollTop = logContainer.scrollHeight;
        }
    </script>
</html>

Product Page | Product Documentation | Blog |API Reference | Free Support | Temporary License

Keywords

Excel

FAQs

Package last updated on 13 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.