对不起我的英文:(
我使用过这段代码:
for (int i = val3; i < to_val3; i++)
{
TextBox tbx4 = (TextBox)(from t4 in this.Controls.OfType<TextBox>() where t4.Name == i.ToString() select t4).First();
str4 = tbx4.Text;
if (!string.IsNullOrWhiteSpace(str4.Split(' ')[4]))
{
get_excel(str4);
}
else
{
MessageBox.Show("Error!, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
并将字符串"str4"
发送到函数get_excel
:
Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook ObjWorkBook;
Microsoft.Office.Interop.Excel.Worksheet ObjWorkSheet;
ObjWorkBook = ObjExcel.Workbooks.Open("C:\\Шаблон.xls");
ObjWorkSheet = ObjWorkBook.Sheets[2];
ObjWorkSheet.Cells[4, 4] = str;
ObjWorkSheet.Cells[5, 5] = str;
ObjWorkSheet.Cells[6, 6] = str;
ObjWorkSheet.Cells[7, 7] = str;
ObjExcel.Visible = false;
ObjExcel.UserControl = true;
ObjExcel.DisplayAlerts = false;
ObjWorkBook.SaveAs("C:\\Шаблон_Изменен.xls");
ObjExcel.Quit();
我的问题:我想从循环(for)中获取变量的第一个值