私は C# の専門家ではありませんが、上記のように EntireRow を使用する必要があります。探している文字列は、.Address
プロパティから取得できます。例えば
private void button1_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.Application xlexcel;
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
Microsoft.Office.Interop.Excel.Range xlRange;
object misValue = System.Reflection.Missing.Value;
xlexcel = new Excel.Application();
xlWorkBook = xlexcel.Workbooks.Add();
// Set Sheet 1 as the sheet you want to work with
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlRange = xlWorkSheet.get_Range("A7:A9,A12,A14", misValue);
MessageBox.Show(xlRange.EntireRow.Address);
xlRange = xlWorkSheet.get_Range(xlRange.EntireRow.Address, misValue);
MessageBox.Show(xlRange.Address);
}
したがって、上記のように書くことができます
private void button1_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.Application xlexcel;
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
Microsoft.Office.Interop.Excel.Range xlRange;
object misValue = System.Reflection.Missing.Value;
xlexcel = new Excel.Application();
xlWorkBook = xlexcel.Workbooks.Add();
// Set Sheet 1 as the sheet you want to work with
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlRange = xlWorkSheet.get_Range("$7:$9,$12:$12,$14:$14", misValue);
MessageBox.Show(xlRange.Address);
}
パートを見る
xlRange = xlWorkSheet.get_Range("$7:$9,$12:$12,$14:$14", misValue);