Specificare il Nome dell’Est e del Latino di Font nelle Opzioni di Testo di Forma con JavaScript tramite C++

Possibili Scenari di Utilizzo

A volte si desidera visualizzare il testo in un font di lingua dell’Est, ad esempio giapponese, cinese, thailandese, ecc. Aspose.Cells for JavaScript tramite C++ fornisce la proprietà TextOptions.farEastName che può essere usata per specificare il nome del font della lingua dell’Est. Inoltre, puoi anche specificare il nome del font latino usando la proprietà TextOptions.latinName.

Specificare il Nome Estremo Orientale e Latino del Carattere nelle Opzioni di Testo della Forma

Il seguente esempio di codice crea una casella di testo e vi aggiunge del testo giapponese. Poi specifica i nomi dei caratteri Latin e Far East del testo e salva il libro di lavoro come file Excel di output. La schermata seguente mostra i nomi dei caratteri Latin e Far East della casella di testo di output in Microsoft Excel.

todo:image_alt_text

Codice di Esempio

<!DOCTYPE html>
<html>
    <head>
        <title>Aspose.Cells Example</title>
    </head>
    <body>
        <h1>Specify Far East and Latin Name of Font in TextOptions of Shape</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, 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 empty workbook.
            const wb = new Workbook();

            // Access first worksheet.
            const ws = wb.worksheets.get(0);

            // Add textbox inside the worksheet.
            const idx = ws.textBoxes.add(5, 5, 50, 200);
            const tb = ws.textBoxes.get(idx);

            // Set the text of the textbox.
            tb.text = "こんにちは世界";

            // Specify the Far East and Latin name of the font.
            tb.textOptions.latinName = "Comic Sans MS";
            tb.textOptions.farEastName = "KaiTi";

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

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