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
|
using Exl = Microsoft.Office.Interop.Excel;
public class ExcelPilot_
{
#region attributs
/// <summary>
/// Nom du fichier à sauvegarder
/// </summary>
private String fileName;
/// <summary>
/// Nom de la feuille à sauvegarder (NOT USED)
/// </summary>
private String sheetName = "Sheet1";
/// <summary>
/// Nom du pivot à donner
/// </summary>
private String pivotName = "Pivot1";
private Exl.Application xlApp;
private Exl.Workbook xlBook;
private Exl.Worksheet xlSheet;
private Exl.PivotTable xlPivot;
/// <summary>
/// Liste des données à mettre en ligne sur le pivot
/// </summary>
private String[] RowField;
/// <summary>
/// Liste des données à mettre en colonne sur le pivot
/// </summary>
private String[] ColField;
/// <summary>
/// Liste des données à calculer sur le pivot
/// </summary>
private String[] DataField;
private bool showColTotal = true;
private bool showRTotal = true;
private int nbRows = 0;
private int nbCols = 0;
private Exl.XlConsolidationFunction consolidationFunction = Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum;
private Microsoft.Office.Interop.Excel.XlChartType _chartType = Microsoft.Office.Interop.Excel.XlChartType.xl3DPie;
private Microsoft.Office.Interop.Excel.XlLegendPosition _chartLegendPosition = Microsoft.Office.Interop.Excel.XlLegendPosition.xlLegendPositionBottom;
private Exl.XlDataLabelsType labelsType = Microsoft.Office.Interop.Excel.XlDataLabelsType.xlDataLabelsShowValue;
private bool dataLabels = true;
#endregion
#region fonctions
#region constructeurs
private void createApp()
{
xlApp = new Exl.ApplicationClass();
xlBook = xlApp.Workbooks.Add(Exl.XlWBATemplate.xlWBATWorksheet);
xlSheet = (Exl.Worksheet)xlBook.Worksheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
xlApp.DisplayAlerts = false;
xlApp.Visible = false;
}
} |
Partager