Question posted 2008 · +24 upvotes
How can I create a table that has its first row and first column both locked, as in Excel, when you activate ‘freeze panes’? I need the table to both scroll horizontally and vertically (a lot of solutions for this exist, but only allow vertical scrolling).
So, when you scroll down in the table, the first row will stay put, since it will have the column headings. This may end up being in a thead, or it may not, whatever makes the solution easier.
When you scroll right, the first column stays put, since it holds the labels for the rows.
I’m pretty certain this is impossible with CSS alone, but can anyone point me toward a JavaScript solution? It needs to work in all major browsers.
Accepted answer +8 upvotes
Oh well, I looked up for scrollable table with fixed column to understand the need of this specific requirement and your question was one of it with no close answers..
I answered this question Large dynamically sized html table with a fixed scroll row and fixed scroll column which inspired to showcase my work as a plugin https://github.com/meetselva/fixed-table-rows-cols
The plugin basically converts a well formatted HTML table to a scrollable table with fixed table header and columns.
The usage is as below,
$('#myTable').fxdHdrCol({
fixedCols : 3, /* 3 fixed columns */
width : "100%", /* set the width of the container (fixed or percentage)*/
height : 500 /* set the height of the container */
});
You can check the demo and documentation here
External references cited (3)
- stackoverflow.com — Large dynamically sized html table with a fixed scroll row…
- github.com — https://github.com/meetselva/fixed-table-rows-cols
- meetselva.github.io — demo and documentation here
Top excel Q&A (6)
- Shortcut to Apply a Formula to an Entire Column in Excel +335 (2011)
- How should I escape commas and speech marks in CSV files so they work in Excel? +136 (2012)
- Convert xlsx to csv in linux command line +96 (2012)
- How to create a link inside a cell using EPPlus +50 (2011)
- IF statement: how to leave cell blank if condition is false ("" does not work) +44 (2013)
- T-SQL: Export to new Excel file +44 (2012)
excel solutions on this site
.