TADBABA
New member
- Joined
- Dec 9, 2020
- Messages
- 3
- Programming Experience
- Beginner
I am new to C# I met this problem:
It says: The name 'excelApp' does not exist in the current context.
I am trying not to let the program initial and create a new Excel file while running.
Any help?
Appreciate it.
It says: The name 'excelApp' does not exist in the current context.
I am trying not to let the program initial and create a new Excel file while running.
Any help?
Appreciate it.
C# code:
public void excel_add(int t1, int t2)
{
row++;
if (excel_init == 0)
{
var excelApp = new Excel.Application();
excelApp.Visible = true;
excelApp.Workbooks.Add();
Excel._Worksheet workSheet = (Excel.Worksheet)excelApp.ActiveSheet;
workSheet.Cells[1, "A"] = "Time";
workSheet.Cells[1, "B"] = "Temperature";
workSheet.Cells[1, "C"] = "Sampling frequency";
workSheet.Cells[1, "D"] = "Display period";
workSheet.Cells[1, "E"] = "Average number";
}
workSheet.Cells[row, "A"] = t1.ToString();
workSheet.Cells[row, "B"] = t2.ToString();
workSheet.Cells[row, "C"] = Sampling_frequency;
workSheet.Cells[row, "D"] = Display_period;
workSheet.Cells[row, "E"] = Average_number;
workSheet.Columns[1].AutoFit();
workSheet.Rows[1].AutoFit();
excel_flag = 1;
excel_init = 1;
//workSheet.Cells[row, "A"] = "32A";
}
Last edited: