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# Excel: Creating a named range?

C# Excel: Creating a named range?

Scheduled Pinned Locked Moved C#
questioncsharptutorial
2 Posts 2 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.
  • G Offline
    G Offline
    Goalie35
    wrote on last edited by
    #1

    How can I create a named range in a C# excel report for cells that aren't lined up next to eachother? I've seen examples on how to create a named range for consecutive cells (i.e. A1:M1), however the cells I need to name are scattered throughout the report (i.e. A1, H3, J9, S17, etc). In excel, I could just do this by holding CTRL + click, but how can I do this in c#? Thanks.

    H 1 Reply Last reply
    0
    • G Goalie35

      How can I create a named range in a C# excel report for cells that aren't lined up next to eachother? I've seen examples on how to create a named range for consecutive cells (i.e. A1:M1), however the cells I need to name are scattered throughout the report (i.e. A1, H3, J9, S17, etc). In excel, I could just do this by holding CTRL + click, but how can I do this in c#? Thanks.

      H Offline
      H Offline
      hamed vojdani
      wrote on last edited by
      #2

      You can Create list of Range insted

          List<Range> myrng = new List<Range>(20);
          myrng.Add(excelWorksheet.get\_Range("A1", "B3"));
      

      and for one cell use Range like this:

      Range rng1 = excelWorksheet.get_Range("A1", "A1");

      then set property of each in loop

      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