Export similar Border Style when Border Style is not supported by Web Browsers with JavaScript via C++
Contents
[
Hide
]
Possible Usage Scenarios
Microsoft Excel supports some types of dashed borders which are not supported by Web Browsers. When you convert such an Excel file into HTML using Aspose.Cells for JavaScript via C++, such borders are removed. However, Aspose.Cells can also support the display of such borders with the HtmlSaveOptions.exportSimilarBorderStyle property. Please set its value as true and the unsupported borders will also be exported to the HTML file.
Export similar Border Style when Border Style is not supported by Web Browsers
The following sample code loads the sample Excel file that contains some unsupported borders as shown in the following screenshot. The screenshot further illustrates the effect of HtmlSaveOptions.exportSimilarBorderStyle property inside the output HTML.
Sample Code
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Export Similar Border Style Example</title>
</head>
<body>
<h1>Export Similar Border Style 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, HtmlSaveOptions } = 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();
// Instantiate Workbook from uploaded file
const workbook = new Workbook(new Uint8Array(arrayBuffer));
// Specify Html Save Options - Export Similar Border Style
const opts = new HtmlSaveOptions();
opts.exportSimilarBorderStyle = true;
// Save the workbook in Html format with specified Html Save Options
const outputData = workbook.save(SaveFormat.Html, opts);
const blob = new Blob([outputData], { type: 'text/html' });
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'outputExportSimilarBorderStyle.html';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download HTML File';
document.getElementById('result').innerHTML = '<p style="color: green;">Export completed successfully! Click the download link to get the HTML file.</p>';
});
</script>
</html>