Fichier excel

cs_Solution Messages postés 92 Date d'inscription lundi 4 avril 2005 Statut Membre Dernière intervention 7 août 2006 - 4 avril 2005 à 15:42
goretoons Messages postés 3 Date d'inscription lundi 27 mars 2006 Statut Membre Dernière intervention 21 septembre 2006 - 10 avril 2006 à 14:40
Bonjour,
est ce qu'il ya quelqu'un qui a manipulé les fichiers excel.aider moi.Je suis entrain de commencer et j'ai rencontré des difficultés:voici mon code.

object missing = System.Reflection.Missing.Value;



string strCurrentPath = Request.PhysicalApplicationPath;



string strXmlPath = strCurrentPath + "test2.xls";


Excel._Application xlApp;


Excel._Workbook xlClasseur;


Excel._Worksheet xlFeuill1;


xlApp =
new Excel.Application();


xlApp.Visible =
false;


xlClasseur = xlApp.Workbooks.Open(strXmlPath,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing, missing,missing,missing,missing);


Excel.Sheets xlFeuilles = xlClasseur.Sheets;


xlFeuill1 = (Excel._Worksheet)xlFeuilles["Activity List"];


Excel.Range r = xlFeuill1.get_Range("A1", "A2");



object[,] cell = (
object[,])r.Cells.Value2 ;


Contenu.Text=cell[1,1].ToString();


erreur acces denied


Merci pour votre aide

1 réponse

goretoons Messages postés 3 Date d'inscription lundi 27 mars 2006 Statut Membre Dernière intervention 21 septembre 2006
10 avril 2006 à 14:40
dans :
xlClasseur = xlApp.Workbooks.Open( strXmlPath ,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing, missing,missing,missing,missing);

strXmlPath doit être du type c:\toto\test2.xls


or
string strXmlPath = strCurrentPath + "test2.xls"; ne comporte pas le deuxième \

Voir à essayer : string strXmlPath = strCurrentPath + [file://\\test2.xls \\test2.xls]; il faut aussi que ce fichier test2 existe !!!
0
Rejoignez-nous