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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace LeProjet_GBDR
{
class ExportComparaison
{
int Cpt = 1;
Microsoft.Office.Interop.Excel._Application Excel_App;
Microsoft.Office.Interop.Excel._Workbook Excel_Clsseur;
public void Ouvre_Excel(String NomBSC,DateTime DateDebut, DateTime DateFin,ArrayList NbreSite,ArrayList NbreCell)
{
Excel_App = new Microsoft.Office.Interop.Excel.ApplicationClass();
Excel_App.ReferenceStyle = Microsoft.Office.Interop.Excel.XlReferenceStyle.xlR1C1;
Excel_App.Visible = false;
object Missing = System.Reflection.Missing.Value;
Excel_Clsseur = Excel_App.Workbooks.Add(Missing);
Microsoft.Office.Interop.Excel.Sheets Excel_Flles = Excel_Clsseur.Sheets;
Microsoft.Office.Interop.Excel._Worksheet Feuil = (Microsoft.Office.Interop.Excel._Worksheet)Excel_Flles[1];
Rempli_Feuille( query, NomFeuille, NbreSite,NbreCell);
Excel_App.Visible = true;
}
private void Rempli_Feuille( string Request, string Name,ArrayList NbreSite,ArrayList NbreCell)
{
Feuil.Name = Name;
int Len = NbreSite.Count;
if (Len > 255)
{
Len = 255;
}
Microsoft.Office.Interop.Excel.Range Rge = Feuil.get_Range(Feuil.Cells[Cpt, 2], Feuil.Cells[Cpt, Len]);
Rge.Cells.Borders.Color = 5;
for (int i = 1; i <= Len; i++)
{
Rge.Cells[1, i] = NbreSite[i-1].ToString();
}
Rge.Cells.AutoFormat(Microsoft.Office.Interop.Excel.XlRangeAutoFormat.xlRangeAutoFormatSimple, 9, 0, 0, 0, 0, 0);
Cpt += 1;
Cursor.Current = Cursors.WaitCursor;
Rge = Feuil.get_Range(Feuil.Cells[1, 1], Feuil.Cells[2, 1]);
Rge.Cells.Borders.Color = 5;
Rge.Cells.Interior.ColorIndex = 16;
Rge.Cells[1, 1] = "LES SITES";
Rge.Cells[2, 1] = "LES CELLULES";
Rge = Feuil.get_Range(Feuil.Cells[Cpt, 2], Feuil.Cells[Cpt, Len]);
Rge.Cells.Borders.Color = 5;
Rge.Cells.AutoFormat(Microsoft.Office.Interop.Excel.XlRangeAutoFormat.xlRangeAutoFormatSimple, 9, 0, 0, 0, 0, 0);
for (int i = 1; i <= Len; i++)
{
Rge.Cells[1, i] = NbreCell[i-1].ToString();
}
Cpt += 1;
Cursor.Current = Cursors.Default;
}
}
} |
Partager