Excel object in C#

  • Thread starter Thread starter Bart Filipski
  • Start date Start date
B

Bart Filipski

Hello,
Does anyone know how looks the syntax of SORT method in
Excel object ( i mean precisely in
Excel.Workbook.Worksheet.Cells.Sort(...) ) I have tryied
in VBA and it works great, but I don't know how to build a
Keys for this method in C# and how to pass this arguments
in this method. Any example howto use this method would be
nice.
Thanks,
Bart
 
private void DemoSort()
{
Excel.Range rng = ThisApplication.get_Range("Fruits",Type.Missing);
rng.Sort(rng.Columns[1, Type.Missing], Excel.XlSortOrder.xlAscending,
rng.Columns[2,Type.Missing], Type.Missing,
Excel.XlSortOrder.xlAscending, Type.Missing,
Excel.XlSortOrder.xlAscending, Excel.XlYesNoGuess.xlNo,
Type.Missing, Type.Missing, Excel.XlSortOrientation.xlSortColumns,
Excel.XlSortMethod.xlPinYin, Excel.XlSortDataOption.xlSortNormal,
Excel.XlSortDataOption.xlSortNormal,
Excel.XlSortDataOption.xlSortNormal);
}
 
Thanks it works. By the way do you know how to permametly
quit from excel application without quiting the C# program
(I mean in my project function objExcel.Quit() doesn't
stop Excel application, which still remains in background )

Regards
Bart
-----Original Message-----
private void DemoSort()
{
Excel.Range rng = ThisApplication.get_Range ("Fruits",Type.Missing);
rng.Sort(rng.Columns[1, Type.Missing], Excel.XlSortOrder.xlAscending,
rng.Columns[2,Type.Missing], Type.Missing,
Excel.XlSortOrder.xlAscending, Type.Missing,
Excel.XlSortOrder.xlAscending, Excel.XlYesNoGuess.xlNo,
Type.Missing, Type.Missing, Excel.XlSortOrientation.xlSortColumns,
Excel.XlSortMethod.xlPinYin,
Excel.XlSortDataOption.xlSortNormal,
Excel.XlSortDataOption.xlSortNormal,
Excel.XlSortDataOption.xlSortNormal);
}
Bart Filipski said:
Hello,
Does anyone know how looks the syntax of SORT method in
Excel object ( i mean precisely in
Excel.Workbook.Worksheet.Cells.Sort(...) ) I have tryied
in VBA and it works great, but I don't know how to build a
Keys for this method in C# and how to pass this arguments
in this method. Any example howto use this method would be
nice.
Thanks,
Bart


.
 
After calling objExcel.Quit(); add
System.RunTime.InteropServices.Marshal.ReleaseComObject(objExcel);
Thanks it works. By the way do you know how to permametly
quit from excel application without quiting the C# program
(I mean in my project function objExcel.Quit() doesn't
stop Excel application, which still remains in background )

Regards
Bart
-----Original Message-----
private void DemoSort()
{
Excel.Range rng = ThisApplication.get_Range ("Fruits",Type.Missing);
rng.Sort(rng.Columns[1, Type.Missing], Excel.XlSortOrder.xlAscending,
rng.Columns[2,Type.Missing], Type.Missing,
Excel.XlSortOrder.xlAscending, Type.Missing,
Excel.XlSortOrder.xlAscending, Excel.XlYesNoGuess.xlNo,
Type.Missing, Type.Missing, Excel.XlSortOrientation.xlSortColumns,
Excel.XlSortMethod.xlPinYin,
Excel.XlSortDataOption.xlSortNormal,
Excel.XlSortDataOption.xlSortNormal,
Excel.XlSortDataOption.xlSortNormal);
}
Bart Filipski said:
Hello,
Does anyone know how looks the syntax of SORT method in
Excel object ( i mean precisely in
Excel.Workbook.Worksheet.Cells.Sort(...) ) I have tryied
in VBA and it works great, but I don't know how to build a
Keys for this method in C# and how to pass this arguments
in this method. Any example howto use this method would be
nice.
Thanks,
Bart


.
 
Back
Top