Manipulation des événements Offices en C#: Exemple d’excel

Author:

Manipulation,des,événements,Offices,en,C#:,Exemple,d'excel
{filelink=15057}

using System;
using System.Reflection;
using Microsoft.Office.Interop.Excel;

namespace office
{
  public class CreationDocumentExcel
  {
    public static AppEvents_WorkbookBeforeCloseEventHandler Event_BeforeBookClose;
    public static DocEvents_ChangeEventHandler Event_ChangeEvent;
    static void Main(string[] args)
    {
        // Créer un document Excel
      Application MyExcel = new ApplicationClass();
      Workbook MyWorkbook = MyExcel.Workbooks.Add(Missing.Value);

      //Modifier le titre du fichier Excel
      MyWorkbook.Windows.get_Item(1).Caption = "Utilisation d'Excel depuis C#";

      // Créer trois Feuilles pour le document
      Worksheet Feuil1 = (Worksheet)MyWorkbook.Worksheets.get_Item(1);
      Worksheet Feuil2 = (Worksheet)MyWorkbook.Worksheets.get_Item(2);
      Worksheet Feuil3 = (Worksheet)MyWorkbook.Worksheets.get_Item(3);

      // Activer la Feuille numéro 2
      Feuil2.Activate();
      MyExcel.Visible = true;
      MyExcel.UserControl = true;
    }

  }

}

Leave a Reply

Your email address will not be published. Required fields are marked *