Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# EPPlus How to hide range of columns

C# EPPlus How to hide range of columns

Scheduled Pinned Locked Moved C#
csharptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mou_kol
    wrote on last edited by
    #1

    I am working with EPPlus which generate excel file. now i have to hide range of columns. this code i used to hide range of columns in one go.

    var rangecol = ws.Cells["M1:P1"];
    var hiddenColumns = rangecol
    .Select(cell => cell.Start.Column)
    .Distinct()
    .Select(rangecol.Worksheet.Column)
    .ToList();

    foreach (var column in hiddenColumns)
    {
    column.Hidden = true;
    }

    the above code is working and hiding columns but if there are 4 columns in range then it is hiding 4 columns individually not hide in one block. i want 4 columns should be hide in one block instead of 4 blocks. please tell me what mistake is there in my code for which groups of columns are not getting hidden in one block. Thanks

    Richard DeemingR V 2 Replies Last reply
    0
    • M Mou_kol

      I am working with EPPlus which generate excel file. now i have to hide range of columns. this code i used to hide range of columns in one go.

      var rangecol = ws.Cells["M1:P1"];
      var hiddenColumns = rangecol
      .Select(cell => cell.Start.Column)
      .Distinct()
      .Select(rangecol.Worksheet.Column)
      .ToList();

      foreach (var column in hiddenColumns)
      {
      column.Hidden = true;
      }

      the above code is working and hiding columns but if there are 4 columns in range then it is hiding 4 columns individually not hide in one block. i want 4 columns should be hide in one block instead of 4 blocks. please tell me what mistake is there in my code for which groups of columns are not getting hidden in one block. Thanks

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      What do you mean by "hidden in one block"? As far as I can see, at least in Microsoft Excel, there is no behavioural difference a sheet with four adjacent columns hidden one-by-one and a sheet where the four columns were selected and all four were hidden at the same time.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • M Mou_kol

        I am working with EPPlus which generate excel file. now i have to hide range of columns. this code i used to hide range of columns in one go.

        var rangecol = ws.Cells["M1:P1"];
        var hiddenColumns = rangecol
        .Select(cell => cell.Start.Column)
        .Distinct()
        .Select(rangecol.Worksheet.Column)
        .ToList();

        foreach (var column in hiddenColumns)
        {
        column.Hidden = true;
        }

        the above code is working and hiding columns but if there are 4 columns in range then it is hiding 4 columns individually not hide in one block. i want 4 columns should be hide in one block instead of 4 blocks. please tell me what mistake is there in my code for which groups of columns are not getting hidden in one block. Thanks

        V Offline
        V Offline
        Victor Nijegorodov
        wrote on last edited by
        #3

        In VBA it would be (for the columns from D to F):

        Columns("D:F").Select
        Selection.EntireColumn.Hidden = True
        

        Try to find something similar in C#

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups