Link DataGridView with a dynamic excel

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have an a datagridview that I create on my form, I would like to display which information is availlable on a specified sheet, with a specified cell.
But the problem is a bit more complex because the excel file changes dinamically, and i want to the datagridview display in direct time what is in the excel file, I have no clue if that is possible.
I did the creation of the datagridview and I manage my excel sheet :

int numLastSheet = xlWorkbook.Worksheets.Count;
Worksheet xlNewSpreadTemplate = (Worksheet)xlWorkbook.Worksheets.Item[Variables.strSheetStratSpread];
xlNewSpreadTemplate.Copy(Type.Missing, xlWorkbook.Worksheets.Item[numLastSheet]);
xlNewSpreadTemplate = (Worksheet)xlWorkbook.Worksheets.Item[numLastSheet + 1];
xlNewSpreadTemplate.Name = strategyItemSpread.paramConsoleStrategyName;
xlWorkbook.Save();
var dataGridView = new DataGridView();
strategyItemSpread.consoleStrategyItemBlock.Controls.Add(dataGridView);
dataGridView.Location = new Point(75, 40);
dataGridView.Size = new Size(700, 70);
CreateCellsDGV(dataGridView, 6, 1, strategyItemSpread.Name);
dataGridView.Name = "strategySpreadDgv" + Variables.maxIDFutureStrategy;
Moreover I know how to interact between them with this line :dataGridView.Rows[1].Cells[1].Value = (..)
Now lets say I want in the: - first column the element dynamically manage of B11 in the excel - second column the element B12 (...)
any idea ?

View the full article
 
Back
Top