Ampliando texto de derecha a izquierda al exportar archivo de Excel a HTML con JavaScript vía C++
Contents
[
Hide
]
Aspose.Cells ahora admite expandir texto de derecha a izquierda al exportar archivos Excel a HTML. Esta función se ha implementado desde la v8.9.0.0. Ahora, si su archivo Excel de origen contiene algún texto que se expande de derecha a izquierda, entonces Aspose.Cells lo exportará a HTML correctamente.
Expandir texto de derecha a izquierda al exportar archivo Excel a HTML
El siguiente código de muestra convierte el archivo de Excel de muestra en HTML. Esta captura de pantalla muestra cómo se ve el archivo de Excel de muestra en Microsoft Excel 2013.

Esta captura de pantalla muestra el HTML de salida generado con una versión anterior.

Esta captura de pantalla muestra el HTML de salida generado con una versión más reciente.

Como puede ver en las capturas de pantalla, la nueva versión expande correctamente el texto alineado a la derecha hacia la izquierda, al igual que Microsoft Excel.
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Expand Text From Right To Left 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, CellsHelper } = 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');
const resultDiv = document.getElementById('result');
if (!fileInput.files.length) {
resultDiv.innerHTML = '<p style="color: red;">Please select an Excel file.</p>';
return;
}
const file = fileInput.files[0];
const arrayBuffer = await file.arrayBuffer();
// Load source excel file inside the workbook object
const wb = new Workbook(new Uint8Array(arrayBuffer));
// Get CellsHelper version (converted from getVersion())
const version = CellsHelper.version;
// Save workbook in html format
const outputData = wb.save(SaveFormat.Html);
const blob = new Blob([outputData], { type: 'text/html' });
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = `ExpandTextFromRightToLeft_out_${version}.html`;
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download HTML File';
resultDiv.innerHTML = '<p style="color: green;">Workbook converted to HTML successfully. Click the download link to get the result.</p>';
});
</script>
</html>