Freeze First Column(s) of Excel Worksheet with JavaScript via C++
Introduction
In this article, we will learn how to freeze left columns. When you have a huge amount of data in a row, you may be unable to see the left columns when horizontally scrolling the worksheet. You can freeze and lock the first column(s) so that you can see that frozen portion even when the rest of the data is being scrolled. You can easily see headers in the left columns.
Freeze Columns In Excel

- If you want to freeze left column(s), then first select the column to the right of the column that needs to be frozen.
- Click View > Freeze Panes.
- On the drop‑down menu, click Freeze First Column.
- If you scroll horizontally, the first column remains in view.

As you can see, the 1st column is frozen, and the first column is always locked on the left side of the view when you scroll horizontally.
Freeze Columns let you view long data without the hassle of keeping track of the first column.
Freeze Columns with Aspose.Cells for JavaScript via C++
It’s simple to freeze first column(s) with Aspose.Cells for JavaScript via C++.
Please use the Worksheet.freezePanes(number, number, number, number) method to freeze column(s) at the selected column.
- Construct a Workbook to open a file or create an empty one.
- Freeze the first column with the
Worksheet.freezePanes()method. - Save the file.
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Freeze Panes Example</title>
</head>
<body>
<h1>Freeze Panes 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, 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();
// Instantiate a new Workbook from the uploaded file
const workbook = new Workbook(new Uint8Array(arrayBuffer));
// Freezing panes at the second column on the first worksheet
const worksheet = workbook.worksheets.get(0);
worksheet.freezePanes("B1", 0, 1);
// Saving the file and preparing download link
const outputData = workbook.save(SaveFormat.Xlsx);
const blob = new Blob([outputData], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'frozen.xlsx';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download Frozen Excel File';
document.getElementById('result').innerHTML = '<p style="color: green;">Freeze panes applied successfully! Click the download link to get the modified file.</p>';
});
</script>
</html>
Attached sample source Excel file.