Disabilitare il ritorno a capo del testo per le etichette dei dati del grafico con JavaScript tramite C++
Contents
[
Hide
]
Microsoft Excel 2013 consente agli utenti di abilitare o disabilitare il testo all’interno delle etichette dati del grafico. Per impostazione predefinita, il testo all’interno delle etichette dati del grafico è nello stato di testo a capo.
Aspose.Cells fornisce la proprietà DataLabels.isTextWrapped() che puoi impostare su true o false per abilitare o disabilitare rispettivamente l’inviluppo del testo delle etichette dei dati.
Il campione di codice sottostante mostra come disabilitare il testo a capo per le etichette dati del grafico.
<!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>