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