1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Microsoft.Office.Interop.Excel.Application appli;
Microsoft.Office.Interop.Excel._Workbook classeur;
Microsoft.Office.Interop.Excel._Worksheet feuille;
object M = System.Reflection.Missing.Value;
object FileName = ""+textBox11.Text+"";
//try
//{
appli = new Microsoft.Office.Interop.Excel.Application();
//appli.Visible = true;
//---------- création du classeur ---------
classeur = (Microsoft.Office.Interop.Excel._Workbook)(appli.Workbooks.Open(""+textBox11.Text+"", M, M, M, M, M, M, M, M, M, M, M, M, M, M));
//------ activer la feuille ----------
feuille = (Microsoft.Office.Interop.Excel._Worksheet)classeur.ActiveSheet;
DataRow dr = c.ds.Tables["compte_banque"].NewRow(); -----lexception est levée ici ---------
for (int i = 1; i < feuille.Rows.Count; i++)
{
dr[0] = feuille.Cells[i, 1];
dr[1] = feuille.Cells[i, 2];
dr[2] = feuille.Cells[i, 3];
dr[3] = feuille.Cells[i, 4];
dr[4] = feuille.Cells[i, 5];
dr[5] = feuille.Cells[i, 6];
c.ds.Tables["compte_banque"].Rows.Add(dr);
} |
Partager