How to Freeze Top Row and Apply Filter in Excel Automation with C#

前端 未结 5 1332
轮回少年
轮回少年 2021-02-02 06:24

I have automation to create an Excel document from C#. I am trying to freeze the top row of my worksheet and apply filter. This is the same as in Excel 2010 if you select View >

5条回答
  •  猫巷女王i
    2021-02-02 06:41

    workSheet.EnableAutoFilter = true; 
    workSheet.Cells.AutoFilter(1); 
    
    //Set the header-row bold
    workSheet.Range["A1", "A1"].EntireRow.Font.Bold = true;  
    
    //Adjust all columns
    workSheet.Columns.AutoFit(); 
    

    There could be some System.Reflection.Missing.Value that need to be passed with the arguments, but this was VB.Net code I've converted out of my mind.

提交回复
热议问题