1. Products
  2.   Spreadsheet
  3.   JavaScript
  4.   Aspose.Cells for JavaScript via C++

Aspose.Cells for JavaScript via C++

 
 

JavaScript Library to Create & Convert Excel Worksheet to PDF

Aspose.Cells for JavaScript via C++ enables Software Developers to Create, Edit, Manipulate and Convert Excel Workbook to XLS, XLSX, XLSB, XLSM, ODS, CSV, and HTML Formats.

What is Aspose.Cells for JavaScript via C++?

Aspose.Cells for JavaScript via C++ is a powerful, high-performance library that enables software developers to create, manipulate, convert, and render Excel spreadsheets directly in browser environments or Node.js applications. Built on WebAssembly technology, this library delivers near-native performance without requiring Microsoft Excel or any server-side dependencies. Whether you're building data visualization dashboards, document generation tools, or complex data processing pipelines, the library provides a comprehensive solution for all your spreadsheet needs.

Aspose.Cells for JavaScript via C++ is a feature-rich API that brings enterprise-grade Excel functionality to JavaScript applications. It supports multiple file formats including XLS, XLSX, XLSB, XLSM, ODS, CSV, TSV, SpreadsheetML, HTML and others, making it a versatile choice for diverse business requirements. The library leverages WebAssembly to achieve exceptional performance directly in web browsers, eliminating the need for server processing and enabling truly serverless web applications. The library's lightweight runtime footprint makes it ideal for modern web applications where performance and user experience are paramount. Unlike traditional server-based solutions, Aspose.Cells for JavaScript via C++ processes spreadsheets entirely on the client side, reducing server load and improving response times.

Previous Next

Getting Started with Aspose.Cells for JavaScript via C++

Just add the following script tag in the browser in order to get started with Aspose.Cells for JavaScript via C++

Aspose.Cells for JavaScript via C++ via NPM

npm i aspose.cells.js 

Excel File Creation & Manipulation via JavaScript

Aspose.Cells for JavaScript via C++ library provides complete control over Excel workbook creation and modification inside JavaScript applications. The library is very easy to handle and enables software developers to programmatically create new workbooks, add worksheets, manipulate cells, and organize data with ease. Here is a very useful example that demonstrates the fundamental process of creating an Excel workbook in XSLX format using JavaScript library. 

How to Create New Excel XLSX Workbook via JavaScript Library?

// Load the Aspose.Cells module
const aspose-cells = require("aspose-cells-cloud");

// Initialize the configuration and API instance (for cloud version) or use the on-premise API.
// Note: The following example demonstrates the conceptual structure. Actual initialization may vary.
const cellsApi = new aspose-cells.CellsApi(/* Your API Key and SID */);

// For the on-premise version, you would typically work with Workbook and Worksheet objects directly.
const aspose = require('aspose.cells'); // Hypothetical import for on-premise

// Create a new Workbook object
let workbook = new aspose.cells.Workbook();

// Access the first worksheet
let worksheet = workbook.getWorksheets().get(0);

// Access cell "A1" in the first worksheet
let cells = worksheet.getCells();
let cell = cells.get("A1");

// Set a value for the cell
cell.setValue("Hello, Aspose.Cells from Node.js!");

// Save the workbook
workbook.save("output/NewWorkbook.xlsx");
console.log("New workbook created successfully!");

Excel File Format Conversion via JavaScript Library

One of the most powerful features is the ability to convert between different file formats seamlessly. This is particularly useful for generating reports in various formats. Aspose.Cells for JavaScript via C++ has provided complete functionality for loading and converting spreadsheet files to various other file formats such as Excel (XLS, XLSX, XLSB, XLSM), ODS, CSV, and HTML formats. This example demonstrates Excel to PDF conversion. We read an uploaded Excel file as an ArrayBuffer, create a Workbook object from it, and then save it in PDF format.

How to Convert Excel XLSX File to PDF via JavaScript Library?


        const { Workbook, SaveFormat } = AsposeCells;
        
        AsposeCells.onReady({
            license: "/lic/aspose.cells.enc",
            fontPath: "/fonts/",
            fontList: [
                "arial.ttf",
                "NotoSansSC-Regular.ttf"
            ]
        }).then(() => {
            console.log("Aspose.Cells initialized");
        });

        document.getElementById('runExample').addEventListener('click', async () => {
            const fileInput = document.getElementById('fileInput');
            const resultDiv = document.getElementById('result');

            if (!fileInput.files.length) {
                resultDiv.innerHTML = '

Please select an Excel file.

'; return; } const file = fileInput.files[0]; const arrayBuffer = await file.arrayBuffer(); // Instantiating a Workbook object by opening the Excel file through the file stream const workbook = new Workbook(new Uint8Array(arrayBuffer)); // Save the document in PDF format const outputData = workbook.save(SaveFormat.Pdf); const blob = new Blob([outputData], { type: 'application/pdf' }); const downloadLink = document.getElementById('downloadLink'); downloadLink.href = URL.createObjectURL(blob); downloadLink.download = 'output.pdf'; downloadLink.style.display = 'block'; downloadLink.textContent = 'Download PDF File'; resultDiv.innerHTML = '

Conversion completed successfully! Click the download link to get the PDF file.

'; });

Formula Calculation Engine via JavaScript

Aspose.Cells for JavaScript via C++ includes a powerful formula calculation engine that supports complex Excel formulas, including built-in functions, array formulas, and user-defined functions. The library supports complex nested formulas and automatically handles cell references and dependencies. Software developers can easily use various Excel functions including SUM, AVERAGE, MAX, MIN, IF, and VLOOKUP. The setFormula() method assigns formulas to cells, and calculateFormula() evaluates all formulas in the workbook. Here is a simple example demonstrates the formula calculation capabilities of Aspose.Cells.

How to Apply and Work with Various Formulas in Excel Workbook via JavaScript Library?


function demonstrateFormulas() {
    const workbook = new Workbook();
    const worksheet = workbook.getWorksheets().get(0);
    const cells = worksheet.getCells();
    
    // Add sample data
    cells.get("A1").putValue("Sales Q1");
    cells.get("A2").putValue(15000);
    cells.get("A3").putValue(18000);
    cells.get("A4").putValue(22000);
    cells.get("A5").putValue(19500);
    
    // SUM formula
    cells.get("A6").setFormula("=SUM(A2:A5)");
    
    // AVERAGE formula
    cells.get("B1").putValue("Average");
    cells.get("B2").setFormula("=AVERAGE(A2:A5)");
    
    // MAX and MIN formulas
    cells.get("C1").putValue("Maximum");
    cells.get("C2").setFormula("=MAX(A2:A5)");
    
    cells.get("D1").putValue("Minimum");
    cells.get("D2").setFormula("=MIN(A2:A5)");
    
    // Conditional formula with IF
    cells.get("E1").putValue("Performance");
    cells.get("E2").setFormula("=IF(B2>20000,\"Excellent\",IF(B2>15000,\"Good\",\"Needs Improvement\"))");
    
    // VLOOKUP example
    cells.get("G1").putValue("Product");
    cells.get("H1").putValue("Price");
    cells.get("G2").putValue("A");
    cells.get("H2").putValue(100);
    cells.get("G3").putValue("B");
    cells.get("H3").putValue(200);
    
    cells.get("J1").putValue("Lookup");
    cells.get("J2").putValue("B");
    cells.get("K1").putValue("Result");
    cells.get("K2").setFormula("=VLOOKUP(J2,G2:H3,2,FALSE)");
    
    // Calculate all formulas
    workbook.calculateFormula();
    
    return workbook;
}

Create & Manipulate Charts via JavaScript Library

Aspose.Cells for JavaScript via C++ has provided complete support for creating and managing professional charts and graphs to visualize your data effectively inside JavaScript applications. The library supports all standard Excel chart types including column, bar, line, pie, scatter, and more. It is also very easy to customize the chart by setting titles for the chart itself and both axes, and enable data labels to display values on the columns. This example creates a column chart to visualize monthly sales data using JavaScript commands.

How to Create a Column Chart in Excel Worksheet via JavaScript Library?


function createChartExample() {
    const workbook = new Workbook();
    const worksheet = workbook.getWorksheets().get(0);
    const cells = worksheet.getCells();
    
    // Add chart data
    cells.get("A1").putValue("Month");
    cells.get("B1").putValue("Sales");
    cells.get("A2").putValue("January");
    cells.get("B2").putValue(25000);
    cells.get("A3").putValue("February");
    cells.get("B3").putValue(28000);
    cells.get("A4").putValue("March");
    cells.get("B4").putValue(32000);
    cells.get("A5").putValue("April");
    cells.get("B5").putValue(30000);
    
    // Add a column chart
    const chartIndex = worksheet.getCharts().add(
        AsposeCells.ChartType.Column,
        5, 0, 15, 5
    );
    
    const chart = worksheet.getCharts().get(chartIndex);
    
    // Set chart data source
    chart.setChartDataRange("A1:B5", true);
    
    // Customize chart title
    chart.getTitle().setText("Monthly Sales Report");
    chart.getTitle().getFont().setBold(true);
    chart.getTitle().getFont().setSize(14);
    
    // Customize axis titles
    chart.getCategoryAxis().getTitle().setText("Months");
    chart.getValueAxis().getTitle().setText("Sales Amount ($)");
    
    // Show data labels
    chart.getNSeries().get(0).getDataLabels().setShowValue(true);
    
    return workbook;
}