Excel.Application excel= new Excel.Application();
int rowIndex=1;
int colIndex=0; excel.Application.Workbooks.Add(true);
DataTable table=GetData();
foreach(DataColumn col in table.Columns)
{
colIndex++;
excel.Cells[1,colIndex]=col.ColumnName;
} foreach(DataRow row in table.Rows)
{
rowIndex++;
colIndex=0;
foreach(DataColumn col in table.Columns)
{
colIndex++;
excel.Cells[rowIndex,colIndex]=row[col.ColumnName].ToString();
}
}excel.Cells[rowIndex,colIndex]这句定位。
int rowIndex=1;
int colIndex=0; excel.Application.Workbooks.Add(true);
DataTable table=GetData();
foreach(DataColumn col in table.Columns)
{
colIndex++;
excel.Cells[1,colIndex]=col.ColumnName;
} foreach(DataRow row in table.Rows)
{
rowIndex++;
colIndex=0;
foreach(DataColumn col in table.Columns)
{
colIndex++;
excel.Cells[rowIndex,colIndex]=row[col.ColumnName].ToString();
}
}excel.Cells[rowIndex,colIndex]这句定位。
case 2: Worksheets("Sheet1").Range("B5")reference:
ms-help://MS.VSCC/MS.MSDNVS.2052/modcore/html/deovrTheRangeProperty.htmhttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrlrfofficeobjectmodel.asp