我正嘗試使用NetOffice在我的c#應用程序中創建excel工作簿,並且遇到了一個嘗試重命名工作表和對單元格範圍進行排序的障礙。以下代碼行無法被NetOffice識別,我正在努力尋找一種方法來重命名工作表並使用NetOffice對單元格範圍進行排序。如何使用NetOffice重命名Excel工作表?
workbook.Worksheets[sheetCountPlusONe].name = "Event " + sheetCountPlusONe.ToString() + " Results";
而且這也行不通。這是我聲明和分選一系列單元格的地方:
Excel.Range valueRange;
Excel.Range placeRange;
placeRange = worksheet.get_Range("A14", "A" + (14 + (registrationForm.numberofCompetitors - 1)).ToString());
valueRange = worksheet.get_Range("A14", "K"+(14+(registrationForm.numberofCompetitors-1)).ToString());
valueRange.Sort(valueRange.Columns[3, Type.Missing], Excel.XlSortOrder.xlDescending, Type.Missing, Type.Missing, Excel.XlSortOrder.xlAscending, Type.Missing, Excel.XlSortOrder.xlAscending, Excel.XlYesNoGuess.xlGuess, Type.Missing, Type.Missing, Excel.XlSortOrientation.xlSortColumns, Excel.XlSortMethod.xlPinYin, Excel.XlSortDataOption.xlSortNormal, Excel.XlSortDataOption.xlSortNormal, Excel.XlSortDataOption.xlSortNormal);
placeRange.Sort(placeRange.Columns[1, Type.Missing], Excel.XlSortOrder.xlAscending, Type.Missing, Type.Missing, Excel.XlSortOrder.xlAscending, Type.Missing, Excel.XlSortOrder.xlAscending, Excel.XlYesNoGuess.xlGuess, Type.Missing, Type.Missing, Excel.XlSortOrientation.xlSortColumns, Excel.XlSortMethod.xlPinYin, Excel.XlSortDataOption.xlSortNormal, Excel.XlSortDataOption.xlSortNormal, Excel.XlSortDataOption.xlSortNormal);
您是否試過。名稱? [此引用(MSDN)](http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.name.aspx#Y0)將其顯示爲大寫屬性。 –
是的,我做了,它的工作有點。我希望有更多關於如何在線使用NetOffice的文檔。該網站只是很有幫助。我在執行時遇到問題。 – user1546315