Headings and Body Theme Font
The default font will automatically change when the region setting is changed.
If the default font is changed, the row height and column width are also changed, and it may even mess up the page layout.
What causes the default font to change?
If an Excel theme font is set, Excel will automatically switch between different fonts based on the current language environment.
Headings and Body Theme Font in Excel
In Excel, select the Home tab and click on the font dropdown box; you will see Theme Fonts with two theme fonts: Calibri Light (Headings) and Calibri (Body) at the top when using the English regional setting.

If a Theme Font is selected, the font name will display differently in different regions. If you do not want the font to automatically change in different regions, do not select the two Theme Fonts.
Changing Headings and Body Font Programmatically
With Aspose.Cells for JavaScript via C++, we can check whether the default font is a theme font or set the theme font using the Font.schemeType property.
The following sample code shows how to manipulate the theme font.
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Change Theme Font 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, FontSchemeType, 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 from the uploaded file
const workbook = new Workbook(new Uint8Array(arrayBuffer));
// Accessing and modifying the default style and its font scheme
let defaultStyle = workbook.defaultStyle;
let font = defaultStyle.font;
let schemeType = font.schemeType;
if (schemeType === FontSchemeType.Major || schemeType === FontSchemeType.Minor) {
console.log("It's a theme font");
}
// Change theme font to a normal font
font.schemeType = FontSchemeType.None;
// Assign the modified default style back to the workbook
workbook.defaultStyle = defaultStyle;
// Saving the modified Excel file
const outputData = workbook.save(SaveFormat.Xlsx);
const blob = new Blob([outputData]);
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'Book1.modified.xlsx';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download Modified Excel File';
document.getElementById('result').innerHTML = '<p style="color: green;">Theme font changed successfully! Click the download link to get the modified file.</p>';
});
</script>
</html>
Dynamically Get Local Theme Font Programmatically
Sometimes, our servers and users' machines are not in the same region. How can we obtain the same font that users want for file processing?
We have to set the system regional settings before loading the file with the LoadOptions.region method.
The following sample code shows how to get the local theme font.
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Get Default Style Local Font 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, Worksheet, Cell, 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');
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();
// Instantiate a new LoadOptions.
const options = new AsposeCells.LoadOptions();
// Set the customer's region
options.region = AsposeCells.CountryCode.Japan;
// Instantiate a new Workbook using the uploaded file and load options.
const workbook = new Workbook(new Uint8Array(arrayBuffer), options);
// Get the default style
const defaultStyle = workbook.defaultStyle;
// Get the customer's local font.
const localFontName = defaultStyle.font.name;
resultDiv.innerHTML = `<p style="color: green;">Local font name: ${localFontName}</p>`;
});
</script>
</html>