[C# ASP.net] Prbl de caractère dans export vers Excel
Bonjour,
Je vais un export vers Excel via la Dll : Microsoft.Office.Interop.Excel.
Seulement tous les caratères "spéciaux" sont transformés.
Exemple : 'é' devient 'é'
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
oExcelApp = null;
oBooks = null;
oBook = null;
oSheet = null;
// Créer lobjet .
oExcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
oExcelApp.Visible = false; // lafficher ou pas
oBooks = oExcelApp.Workbooks;
oBook = oBooks.Open(nomfichier, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,Missing.Value, Missing.Value, Missing.Value, Missing.Value);
//on active la feuille
oSheet = (Microsoft.Office.Interop.Excel.Worksheet)oExcelApp.Sheets.get_Item("Export");
// ..................
for ( i = 0; i < GridView1.Rows[1].Cells.Count; i++)
{
for (int j = 0; j < GridView1.Rows.Count; j++)
{
oSheet.Cells.Cells[j + 2, i + 1] = GridView1.Rows[j].Cells[i].Text.ToString();
}
}
//puis fermeture Excel |
Merci par avance pour votre aide