C# アプリケーションで NetOffice を使用して Excel ワークブックを作成しようとしていますが、ワークシートの名前を変更しようとしたり、セルの範囲で並べ替えを使用したりするときに問題が発生しました。次のコード行は NetOffice で認識されず、NetOffice を使用してワークシートの名前を変更し、セルの範囲を並べ替える方法を見つけるのに苦労しています。
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);