Implementa Errori e Valori Booleani in Russo o in qualsiasi altra lingua con JavaScript tramite C++
Contents
[
Hide
]
Possibili Scenari di Utilizzo
Se utilizzi Microsoft Excel in Russo o in altre lingue o locali, verranno visualizzati errori e valori booleani secondo quella lingua o locale. Puoi ottenere un comportamento simile usando Aspose.Cells for JavaScript tramite C++ con la proprietà WorkbookSettings.globalizationSettings. Dovrai sovrascrivere i metodi seguenti della classe GlobalizationSettings.
Implementare gli errori e il valore booleano in russo o in qualsiasi altra lingua
Il seguente codice di esempio illustra come implementare gli errori e il valore booleano in russo o in qualsiasi altra lingua. Controlla il File Excel di esempio utilizzato in questo codice e il suo PDF di output. Lo screenshot mostra la differenza tra il file Excel di esempio e il PDF di output a titolo di riferimento.

Codice di Esempio
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
<meta charset="utf-8" />
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
#downloadLink { display: none; margin-top: 10px; display: inline-block; }
#result p { margin: 8px 0; }
</style>
</head>
<body>
<h1>Russian Globalization Example</h1>
<input type="file" id="fileInput" accept=".xls,.xlsx" />
<button id="runExample">Run Example</button>
<a id="downloadLink">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");
});
// Russian Globalization
class RussianGlobalization extends AsposeCells.GlobalizationSettings {
errorValueString(err) {
switch (err.toUpperCase()) {
case "#NAME?":
return "#RussianName-имя?";
}
return "RussianError-ошибка";
}
booleanValueString(bv) {
return bv ? "RussianTrue-правда" : "RussianFalse-ложный";
}
}
document.getElementById('runExample').addEventListener('click', async () => {
const fileInput = document.getElementById('fileInput');
const resultDiv = document.getElementById('result');
resultDiv.innerHTML = '';
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 the source workbook
const workbook = new Workbook(new Uint8Array(arrayBuffer));
// Set GlobalizationSettings in Russian Language
workbook.settings.globalizationSettings = new RussianGlobalization();
// Calculate the formula
workbook.calculateFormula();
// Save the workbook in pdf format
const outputData = workbook.save(SaveFormat.Pdf);
const blob = new Blob([outputData], { type: 'application/pdf' });
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'outputRussianGlobalization.pdf';
downloadLink.style.display = 'inline-block';
downloadLink.textContent = 'Download PDF File';
resultDiv.innerHTML = '<p style="color: green;">Operation completed successfully! Click the download link to get the PDF.</p>';
});
</script>
</html>