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. group rows of excel using c#.

group rows of excel using c#.

Scheduled Pinned Locked Moved C#
questioncsharp
4 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.
  • L Offline
    L Offline
    lucluv
    wrote on last edited by
    #1

    Hi, I want to group rows of excel using c#. how can i do it??? Pls suggest me..

    A 1 Reply Last reply
    0
    • L lucluv

      Hi, I want to group rows of excel using c#. how can i do it??? Pls suggest me..

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2
       ApplicationClass excelApplication;		
      	Workbook excelWorkBook;		
      	Worksheet excelWorkSheet;			
              excelApplication = new ApplicationClass();			excelWorkBook = excelApplication.Workbooks.Add(Type.Missing);			excelWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet) excelWorkBook.ActiveSheet;			excelWorkSheet.get_Range(excelWorkSheet.Cells[1,1],excelWorkSheet.Cells[1,2]).Merge(Type.Missing);			excelWorkSheet.Cells[1,1] = "Merged Text";			excelWorkSheet.get_Range("A1","A1").Interior.ColorIndex = 37;	excelWorkSheet.get_Range("A1","A1").Interior.Pattern  = XlPattern.xlPatternSolid;			excelWorkSheet.get_Range("A1","A1").Font.Bold = true;			excelWorkBook.SaveAs("C:\\NewExcel_CSharp.xls",Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);			excelApplication.Quit();
      

      and for that you need

      Microsoft.Office.Interop.Excel.dll
      

      Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

      A 1 Reply Last reply
      0
      • A Abhijit Jana
         ApplicationClass excelApplication;		
        	Workbook excelWorkBook;		
        	Worksheet excelWorkSheet;			
                excelApplication = new ApplicationClass();			excelWorkBook = excelApplication.Workbooks.Add(Type.Missing);			excelWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet) excelWorkBook.ActiveSheet;			excelWorkSheet.get_Range(excelWorkSheet.Cells[1,1],excelWorkSheet.Cells[1,2]).Merge(Type.Missing);			excelWorkSheet.Cells[1,1] = "Merged Text";			excelWorkSheet.get_Range("A1","A1").Interior.ColorIndex = 37;	excelWorkSheet.get_Range("A1","A1").Interior.Pattern  = XlPattern.xlPatternSolid;			excelWorkSheet.get_Range("A1","A1").Font.Bold = true;			excelWorkBook.SaveAs("C:\\NewExcel_CSharp.xls",Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);			excelApplication.Quit();
        

        and for that you need

        Microsoft.Office.Interop.Excel.dll
        

        Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3
        ApplicationClass excelApplication;	
        Workbook excelWorkBook;
        Worksheet excelWorkSheet;
        excelApplication = new ApplicationClass();
        excelWorkBook = excelApplication.Workbooks.Add(Type.Missing);
        excelWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet) excelWorkBook.ActiveSheet;
        excelWorkSheet.get_Range(excelWorkSheet.Cells[1,1],excelWorkSheet.Cells[1,2]).Merge(Type.Missing);
        excelWorkSheet.Cells[1,1] = "Merged Text";
        excelWorkSheet.get_Range("A1","A1").Interior.ColorIndex = 37;
        excelWorkSheet.get_Range("A1","A1").Interior.Pattern  = XlPattern.xlPatternSolid;
        excelWorkSheet.get_Range("A1","A1").Font.Bold = true;
        excelWorkBook.SaveAs("C:\\NewExcel_CSharp.xls",Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);
        excelApplication.Quit();
        

        and for that you need

        Microsoft.Office.Interop.Excel.dll
        

        Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

        L 1 Reply Last reply
        0
        • A Abhijit Jana
          ApplicationClass excelApplication;	
          Workbook excelWorkBook;
          Worksheet excelWorkSheet;
          excelApplication = new ApplicationClass();
          excelWorkBook = excelApplication.Workbooks.Add(Type.Missing);
          excelWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet) excelWorkBook.ActiveSheet;
          excelWorkSheet.get_Range(excelWorkSheet.Cells[1,1],excelWorkSheet.Cells[1,2]).Merge(Type.Missing);
          excelWorkSheet.Cells[1,1] = "Merged Text";
          excelWorkSheet.get_Range("A1","A1").Interior.ColorIndex = 37;
          excelWorkSheet.get_Range("A1","A1").Interior.Pattern  = XlPattern.xlPatternSolid;
          excelWorkSheet.get_Range("A1","A1").Font.Bold = true;
          excelWorkBook.SaveAs("C:\\NewExcel_CSharp.xls",Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);
          excelApplication.Quit();
          

          and for that you need

          Microsoft.Office.Interop.Excel.dll
          

          Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

          L Offline
          L Offline
          lucluv
          wrote on last edited by
          #4

          hi abhijit, Thanx for your response.But I am sorry that your code is not resolving my problem.All i want is to group/ungroup rows(collapse/expand) using c#. ex: In excel select some rows and go to Data->Group and Outline and select group.It will collapse rows with mark '+'.This i want through c# code.

          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