I have a Windows App that analyzes some data an displays some summary information to a text box. I would like to be able to send the detailed information to an Excel file. The button is visible and ready to be clicked. The Excel helper is ready to be used. How can I send the data table to the button click method? The Data Table is local to the "analyzer" method.
The code is structured as follows:
User enters necessary filters and clicks the "Analyze Data" button
private void btn_AnalyzeData_Click(object sender, EventArgs e)
{
//Do all kinds of analysis
DataTable dtInfo = new DataTable();
BuildTableHeaders(dtInfo);
PopulateDataTable(dtInfo);
string[,] strInfo = PopulateStrInfo(dtInfo);
//Display String
dtInfo.Dispose();
}
The user looks at the display and thinks "interesting, I had better look at the detail" and hits the "Send to Excel" button.
private void btn_SendToExcel_Click(object sender, EventArgs e)
{
------Do not know what to do here???
------Since dtInfo is local to the above event I do not know how to pass it to this event
ExcelHelper.CreateXLFile(dtInfo);
}
Thank you.
Rod