Configura un estilo de WordArt predefinido para el texto de la forma con JavaScript a través de C++
Contents
[
Hide
]
Escenarios de uso posibles
Puedes configurar un estilo de WordArt predefinido en el texto de la forma usando Aspose.Cells for JavaScript a través de C++. Utiliza los métodos FontSetting.wordArtStyle(PresetWordArtStyle) o FontSettingCollection.wordArtStyle(PresetWordArtStyle) para este propósito.
Establecer un estilo de WordArt preestablecido al texto de la forma
El siguiente código de ejemplo crea un cuadro de texto con algún texto y luego establece el estilo de WordArt predefinido de su texto usando el método FontSetting.wordArtStyle(PresetWordArtStyle). Así es como se ve el archivo de Excel de salida en Microsoft Excel.

<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example - Set Preset WordArt Style</title>
</head>
<body>
<h1>Set Preset WordArt Style 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 () => {
const resultDiv = document.getElementById('result');
// Create a new workbook (original JavaScript code created a new Workbook without reading a file)
const workbook = new Workbook();
// Access first worksheet
const worksheet = workbook.worksheets.get(0);
// Create a textbox with some text
const textbox = worksheet.shapes.addTextBox(0, 0, 0, 0, 100, 700);
textbox.text = "Aspose File Format APIs";
textbox.font.size = 44;
// Sets preset WordArt style to the text of the shape.
const fntSetting = textbox.richFormattings[0];
fntSetting.wordArtStyle = AsposeCells.PresetWordArtStyle.WordArtStyle3;
// Save the workbook in xlsx format and provide a 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 = 'outputSetPresetWordArtStyle.xlsx';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download Excel File with WordArt';
resultDiv.innerHTML = '<p style="color: green;">Workbook created and ready for download.</p>';
});
</script>
</html>