0

我试图让图例中显示的“A”列中的用户以及栏中用户旁边的数据。我不确定空白数据来自哪里,也不确定为什么显示为“系列”

我还希望左边的值显示在 0% 到 100% 之间,这样每 10% 的用户就更容易阅读。

img2

图像

      Excel.Range dataRange = chartSheet.get_Range("A1", "C" + chart.Rows.Count.ToString());
      //chart.Rows.Count = 2

                        Excel.ChartObjects chartObjects = (Excel.ChartObjects)(excelWorksheet.ChartObjects(Type.Missing));
                        Excel.ChartObject newChartObject = chartObjects.Add(0, 600, 300, 300);

                        object paramChartFormat = 1;
                        object paramCategoryLabels = 0;
                        object paramSeriesLabels = 0;
                        bool paramHasLegend = true;
                        object paramTitle = "Performance Efficiency";
                        object paramCategoryTitle = "Providers";
                        object paramValueTitle = "Percentage";

                        newChartObject.Chart.ChartWizard(dataRange, Excel.XlChartType.xl3DColumn,
                            paramChartFormat, Excel.XlRowCol.xlRows, paramCategoryLabels,
                            paramSeriesLabels, paramHasLegend, paramTitle, paramCategoryTitle,
                            paramValueTitle, Type.Missing);
4

1 回答 1

0

这是我用来解决问题的方法

    Excel.Range dataRange = chartSheet.get_Range("B2", "B" + chart.Rows.Count.ToString());
    dataRange.NumberFormat = "#%";
    dataRange = chartSheet.get_Range("C2", "C" +   chart.Rows.Count.ToString());
                        dataRange.NumberFormat = "#%";

    dataRange = chartSheet.get_Range("A1", "C" + chart.Rows.Count.ToString());

    Excel.ChartObjects chartObjects = (Excel.ChartObjects)(excelWorksheet.ChartObjects(Type.Missing));
    Excel.ChartObject newChartObject = (Excel.ChartObject)chartObjects.Add(0, 600, (100 * chart.Rows.Count), 300);
    Excel.Chart chartPage = newChartObject.Chart;

    chartPage.SetSourceData(dataRange, Type.Missing);
    chartPage.ChartType = Excel.XlChartType.xlColumnClustered;
于 2013-03-19T14:15:46.530 回答