//Variables
protected Excel.Worksheet feuilleExcel;
protected Excel.Range Cellules;
protected Excel.Range UneCellule;
protected Excel.Range DeuxCellules;
protected ExcelApplication xls;
//Open worksheet #1
this.feuilleExcel = (Excel.Worksheet)xls.__Excel.Worksheets[1];
this.feuilleExcel.Activate();
//get entire cells
this.Cellules = this.feuilleExcel.Cells;
//work on 1 cell
this.UneCellule=(Excel.Range)this.Cellules[XListe,YListe];
//value inserted
this.UneCellule.Value=this.ListeTypesCarte[i];
//cell border
this.UneCellule.BorderAround(Excel.XlLineStyle.xlContinuous,Excel.XlBorderWeight.xlThin,Excel.XlColorIndex.xlColorIndexAutomatic,1);
//font style
this.UneCellule.Font.Bold=true;
//background color
this.UneCellule.Interior.Color=16777164;
//work on 2 cells
//insert values on first cell
this.Cellules[X,1]=rs.GetString(0);
//get cells
this.DeuxCellules = (Excel.Range)this.feuilleExcel.get_Range(this.Cellules[X,1],this.Cellules[X,2]);
//cell border
this.DeuxCellules.BorderAround(Excel.XlLineStyle.xlContinuous,Excel.XlBorderWeight.xlThin,Excel.XlColorIndex.xlColorIndexAutomatic,1);
//background color
this.DeuxCellules.Interior.Color=10092543;
//font style
this.DeuxCellules.Font.Bold=true;
***********************************
EXCEL CLASS
***********************************
using System;
using System.Reflection;
namespace ControlOffice
{
public class ExcelApplication
{
public Excel.Application __Excel; // Application interface
public object opt= Missing.Value;
public string f;
public ExcelApplication(string fich)
{
__Excel=new Excel.ApplicationClass();
__Excel.Workbooks.Open(fich,opt,opt,opt,opt,opt,opt,opt,opt,opt,opt,opt, opt);
f =fich;
}
public bool Visible
{
get
{
return __Excel.Visible;
}
set
{
__Excel.Visible=value;
}
}
public Excel.Workbook nomClasseur
{
get
{
return __Excel.ActiveWorkbook;
}
}
public Excel.Worksheet nomFeuil
{
get
{
return (Excel.Worksheet) __Excel.ActiveWorkbook.ActiveSheet;
}
}
public Excel.Range Cellules
{
get
{
return nomFeuil.Cells;
}
}
public void quit(bool save)
{
__Excel.ActiveWorkbook.Close(save,this.opt,this.opt);
__Excel.Quit();
}
}
}