Salva il workbook in formato Strict Open XML Spreadsheet con JavaScript tramite C++

Possibili Scenari di Utilizzo

Aspose.Cells for JavaScript tramite C++ consente di salvare il workbook in formato Strict Open XML Spreadsheet. Per questo scopo, fornisce la proprietà WorkbookSettings.compliance. Se imposti il suo valore a OoxmlCompliance.iso29500_2008_strict, il file Excel di output verrà salvato in formato Strict Open XML Spreadsheet.

Salva il foglio di lavoro nel formato Strict Open XML Spreadsheet

Il seguente esempio di codice crea un workbook, imposta il valore della proprietà WorkbookSettings.compliance su OoxmlCompliance.iso29500_2008_strict e lo salva come file Excel di output. Se apri il file Excel di output in Microsoft Excel e apri la finestra di dialogo Salva con nome…, vedrai il suo formato come Strict Open XML Spreadsheet come mostrato in questa schermata.

todo:image_alt_text

Codice di Esempio

<!DOCTYPE html>
<html>
    <head>
        <title>Save Workbook to Strict Open XML Spreadsheet Format</title>
    </head>
    <body>
        <h1>Save Workbook to Strict Open XML Spreadsheet Format</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, OoxmlCompliance, Utils } = 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();

            // Specify - Strict Open XML Spreadsheet - Format.
            workbook.settings.compliance = OoxmlCompliance.Iso29500_2008_Strict;

            // Access first worksheet and set value in B4
            const worksheet = workbook.worksheets.get(0);
            const b4 = worksheet.cells.get("B4");
            b4.value = "This Excel file has Strict Open XML Spreadsheet format.";

            // Save to output Excel file and provide download link
            const outputData = workbook.save(SaveFormat.Xlsx);
            const blob = new Blob([outputData]);
            const downloadLink = document.getElementById('downloadLink');
            downloadLink.href = URL.createObjectURL(blob);
            downloadLink.download = 'outputSaveWorkbookToStrictOpenXMLSpreadsheetFormat.xlsx';
            downloadLink.style.display = 'block';
            downloadLink.textContent = 'Download Excel File';

            document.getElementById('result').innerHTML = '<p style="color: green;">Workbook created and saved to Strict Open XML Spreadsheet format. Click the download link to get the file.</p>';
        });
    </script>
</html>