Manage settings of Excel spreadsheet files with JavaScript via C++

Workbook Settings Overview

Working with Excel files involves various settings that can be manipulated programmatically using Aspose.Cells for JavaScript via C++. This document outlines how to manage these settings effectively.

Possible Usage Scenarios

The following scenarios illustrate when you might need to manage workbook settings:

  • Adjusting display options
  • Setting calculation mode
  • Configuring page setup parameters

Managing Workbook Settings using Aspose.Cells for JavaScript via C++

This example demonstrates how to manage workbook settings such as calculation options and display settings.

  1. Create a new workbook or load an existing one.
  2. Modify workbook settings as per your requirements.
  3. Save the workbook to persist the changes.

Example Code

<!DOCTYPE html>
<html>
    <head>
        <title>Aspose.Cells Example</title>
    </head>
    <body>
        <h1>Workbook Settings Example</h1>
        <input type="file" id="fileInput" accept=".xls,.xlsx,.csv" />
        <button id="runExample">Run Example</button>
        <a id="downloadLink" style="display: none;">Download Result</a>
        <div id="result"></div>
    </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(() => {
            console.log("Aspose.Cells initialized");
        });

        document.getElementById('runExample').addEventListener('click', async () => {
            // Create a new workbook
            const workbook = new Workbook();

            // Access the settings of the workbook
            const settings = workbook.settings;
            settings.calculationMode = 1; // Manual calculation

            // Display options
            settings.showGridLines = false; // Disable gridlines

            // Save the workbook
            const outputData = workbook.save(SaveFormat.Xlsx);
            const blob = new Blob([outputData]);
            const downloadLink = document.getElementById('downloadLink');
            downloadLink.href = URL.createObjectURL(blob);
            downloadLink.download = 'WorkbookSettingsExample.xlsx';
            downloadLink.style.display = 'block';
            downloadLink.textContent = 'Download Excel File';

            document.getElementById('result').innerHTML = '<p style="color: green;">Workbook created successfully! Click the download link to get the file.</p>';
        });
    </script>
</html>

Key Workbook Settings Properties and Methods

Aspose.Cells for JavaScript via C++ provides a number of properties and methods to adjust workbook settings:

  • Workbook.settings: Accesses the workbook’s settings.
  • Settings.calculationMode: Sets the calculation mode for the workbook.
  • Settings.showGridLines: Enables or disables grid lines on the display.

Conclusion

Managing workbook settings in Aspose.Cells for JavaScript via C++ is straightforward and provides numerous options to customize Excel file behaviors. By utilizing the settings available, you can tailor the workbook to fit your specific requirements.