0
我不能設法改變我的excel圖表在C#中的風格。c#圖表excel風格
我有這樣的: default design
,我想獲得這個: design I try to have
我讀了這個問題很多話題,嘗試過的很多,似乎沒有任何工作.. 。 我設法得到我想要爲我的餅圖,但它不工作對我的「列」 Chart:
我嘗試這樣做:
object paramChartFormat = 1; //tried to change it to 201, 209, ... not working :(
然後這個(在excel中找到了一個名稱與宏,因爲我看到它是獲得我們希望在另一個問題上設計的名稱的方式在這裏在stackoverflow),但設計仍然是藍色列「標準」 :
Microsoft.Office.Interop.Excel.XlChartType.xlColumnStacked;
這裏是我的代碼:
object paramChartFormat = 1;
object paramCategoryLabels = 1;
object paramSeriesLabels = 1;
//bool paramHasLegend = true;
object paramTitle = "Collection";
object paramCategoryTitle = "";
object paramValueTitle = "";
Range dataRange = null;
ChartObjects chartObjects = null;
//ChartObject newChartObject = null;
object paramMissing = Type.Missing;
string tuple = "C" + Row.ToString();
dataRange = sheet.get_Range("A1", tuple);
chartObjects = (ChartObjects)(sheet.ChartObjects(paramMissing));
/*newChartObject = chartObjects.Add(0, 100, 300, 300);
newChartObject.Chart.ChartWizard(dataRange, XlChartType.xl3DColumn, paramChartFormat, XlRowCol.xlRows, paramCategoryLabels, paramSeriesLabels, paramHasLegend, paramTitle, paramCategoryTitle, paramValueTitle, paramMissing);
*/
//Number of copies
Microsoft.Office.Interop.Excel.ChartObject chartObjectnbex = sheet.ChartObjects().Add((float)sheet.get_Range("B1").Left, (float)sheet.get_Range("B"+(Row+2).ToString()).Top, 300, 300);
chartObjectnbex.Chart.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlColumnStacked;
Microsoft.Office.Interop.Excel.Series seriesnbex = chartObjectnbex.Chart.SeriesCollection().Add(sheet.Range["B2:B" + Row.ToString()]);
seriesnbex.XValues = sheet.Range["A2:A" + Row.ToString()];
seriesnbex.Name = "Nombre d'Exemplaires";
//Nbre documents différents
//此代碼(餅圖工作):
Microsoft.Office.Interop.Excel.ChartObject myChart = (Microsoft.Office.Interop.Excel.ChartObject)chartObjects.Add((float)sheet.get_Range("B1").Left, (float)sheet.get_Range("B" + (Row + 77).ToString()).Top, 300, 300);
Microsoft.Office.Interop.Excel.Chart chartPage = myChart.Chart;
Microsoft.Office.Interop.Excel.SeriesCollection seriesCollection = chartPage.SeriesCollection();
Microsoft.Office.Interop.Excel.Series series1 = seriesCollection.NewSeries();
series1.XValues = sheet.Range["A2", "A"+Row.ToString()];
series1.Values = sheet.Range["B2", "B" + Row.ToString()];
chartPage.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlDoughnut;
chartPage.HasTitle = true;
chartPage.ChartTitle.Text = "Nombre d'exemplaires";
Microsoft.Office.Interop.Excel.Axis axis = chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlValue, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary) as Microsoft.Office.Interop.Excel.Axis;
series1.ApplyDataLabels(Microsoft.Office.Interop.Excel.XlDataLabelsType.xlDataLabelsShowPercent, true, true, false, false, false, false, true);
你知道我在做錯什麼來改變設計嗎?
非常感謝,
R.