Desactivar el ajuste de texto para las etiquetas de datos del gráfico con JavaScript vía C++
Contents
[
Hide
]
Microsoft Excel 2013 permite a los usuarios ajustar o desajustar el texto dentro de las etiquetas de datos del gráfico. De forma predeterminada, el texto dentro de las etiquetas de datos del gráfico está en estado desajustado.
Aspose.Cells proporciona una propiedad DataLabels.isTextWrapped() que puedes establecer en true o false para habilitar o deshabilitar el ajuste de texto de las etiquetas de datos respectivamente.
El siguiente ejemplo de código muestra cómo deshabilitar el ajuste de texto para las etiquetas de datos del gráfico.
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Disable Data Label Text Wrapping</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 () => {
const fileInput = document.getElementById('fileInput');
if (!fileInput.files.length) {
document.getElementById('result').innerHTML = '<p style="color: red;">Please select an Excel file.</p>';
return;
}
const file = fileInput.files[0];
const arrayBuffer = await file.arrayBuffer();
// Instantiating a Workbook object by loading uploaded file
const workbook = new Workbook(new Uint8Array(arrayBuffer));
// Access the first worksheet
const worksheet = workbook.worksheets.get(0);
// Access the first chart inside the worksheet
const chart = worksheet.charts.get(0);
// Disable the Text Wrapping of Data Labels in all Series
chart.nSeries.get(0).dataLabels.isTextWrapped = false;
chart.nSeries.get(1).dataLabels.isTextWrapped = false;
chart.nSeries.get(2).dataLabels.isTextWrapped = false;
// Save the workbook 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 = 'Output_out.xlsx';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download Modified 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>