By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,565 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,565 IT Pros & Developers. It's quick & easy.

Visual C# 2005 broken?

P: n/a
JM
I've added Excel 11 as a reference to my project (Visual C# 2005 beta 1) and
added the code below. Problem is when I try my sort the compiler gives
warning about Microsoft.Office.Interop.Excel.Application does not have a
definition for XlSortOrder, and XlYesNoGuess etc. Basically anything in the
line below that starts with "Xl" it does not seem to recognize.... Can
anyone out there give me a hand to figure out what I messed up or what I am
not doing? How do I get these constants to work?

oRng.Sort(oRng.Columns[1, Type.Missing], excel.XlSortOrder.xlAscending,
oRng.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);

using Microsoft.Office.Interop.Excel; // Use Excel
using ExcelApplication = Microsoft.Office.Interop.Excel.Application; //
Create an alias
....
// Create an Excel instance
ExcelApplication excel = new ExcelApplication();
excel.Visible = true; // So we can see Excel.
Workbook workbook = excel.Workbooks.Add(Missing.Value);
Worksheet worksheet = (Worksheet)excel.ActiveSheet;
....
worksheet.get_Range("A1", "H1").Font.Bold = true;
worksheet.get_Range("A1", "H1").Font.Underline = true;
worksheet.get_Range("A1", "H1").HorizontalAlignment =
-4108; // Centre

Range oRng = worksheet.get_Range("A1", "H1");
oRng.EntireColumn.AutoFit();

oRng.Sort(oRng.Columns[1, Type.Missing],
excel.XlSortOrder.xlAscending, oRng.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);

Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.