How to freeze the header row in an Excel spreadsheet exported from ASP.NET

前端 未结 2 467
暖寄归人
暖寄归人 2020-12-21 18:14

I\'m exporting an ASP.NET gridview to Excel using the following function. The formatting is working really well, except I need to freeze the header row in Excel on the expo

2条回答
  •  孤城傲影
    2020-12-21 18:41

    Modify the WorksheetOption element to something like the following:

    
         
         
         
         1
         1
         2
         
          
           3
          
          
           2
          
         
         False
         False
         False
        
    

    Notice the FreezePanes element. I cut this out of a spreadsheet that I had saved as HTML with the first row frozen. When this file is opened with Excel, the first row is frozen.

    EDIT: To have the header row print on each page, you will need something like this:

    
      Print_Area
      1
      =Sheet1!$A$2:$F$97
     
     
      Print_Titles
      1
      =Sheet1!$1:$1
     
    

    You will need to modify the values in the formula dynamically for your data.

提交回复
热议问题