Freezing panels in multiple C # sheets

I am working on creating an MS Excel 2013 report in which all worksheets in the workbook should have a freeze area in column 6 and line 1. I searched on Google, but could not find a solution, how to freeze the panel, the book should be active. I tried a lot, but did not succeed. I will be very grateful if someone can help me.

Excel.Application excel = new Excel.Application();
Excel.Workbook workbook = excel.Workbooks.Open("filelocation");

foreach (Excel.Worksheet ws in workbook.Worksheets)
{
    ws.Application.ActiveWindow.SplitColumn = 6;
    ws.Application.ActiveWindow.SplitRow = 1;
    ws.Application.ActiveWindow.FreezePanes = true;
}

excel.Visible = true;
+4
source share
2 answers

Hope this helps others. I used the ClosedXML library for Excel and after creating each worksheet I used

worksheet.SheetView.Freeze(1,6);  

1, . 6. /. ClosedXML. .

+6

, for, . :

Excel.Application excel = new Excel.Application();
Excel.Workbook workbook = excel.Workbooks.Open("filelocation");

foreach (Excel.Worksheet ws in workbook.Worksheets)
{
    ws.Activate();
    ws.Application.ActiveWindow.SplitColumn = 6;
    ws.Application.ActiveWindow.SplitRow = 1;
    ws.Application.ActiveWindow.FreezePanes = true;
}

excel.Visible = true; 
+1

Source: https://habr.com/ru/post/1524606/


All Articles