简体   繁体   中英

Select specific cell in Excel and go to next row

Using C# how can I "jump" to a specific cell in an Excel spreadsheet and go to the next row? I need to populate an existing spreadsheet with data from a list. This is how I thought it would work:

Globals.LookupTable.Range["A2"].Select();
foreach (CFolderType ft in FolderTypes) {
    Globals.LookupTable.Rows.Next.Value2 = ft.name;
}

This shall move down in column A and insert the values.

Something like this should do the work:

Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.ApplicationClass();
excel.Workbooks.Add(System.Reflection.Missing.Value);
int rowIdx = 2;
foreach (CFolderType ft in FolderTypes) 
{
    Microsoft.Office.Interop.Excel.Range aCell = excel.get_Range("A" + rowIdx.ToString(), System.Reflection.Missing.Value); 
    aRange.Value = ft.name;
    rowIdx++;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM