Excel互操作图隐藏图表区域文本

时间:2016-03-30 19:13:23

标签: .net vb.net excel interop excel-interop

我使用下面的代码(VB.Net和Microsoft Excel Interop)创建了以下图表对象

Dim ColumnChart As Microsoft.Office.Interop.Excel.Chart
                    Dim ColumnChartShape As Microsoft.Office.Interop.Excel.Shape = oSheet.Shapes.AddChart()
                    ColumnChart = ColumnChartShape.Chart
                    CCLastRow = oSheet.Rows.End(Excel.XlDirection.xlDown)
                    CCLR = oSheet.UsedRange.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeLastCell).Row
                    CCLC = oSheet.UsedRange.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeLastCell).Column
                    oSheet.Range("$C$3:" & GetExcelColumn(CCLC) & CCLastRow.Row).NumberFormat = "$#,##0_);($#,##0)"
                    ColumnChartSourceRange = oSheet.Range("$B$3:" & GetExcelColumn(CCLC) & CCLastRow.Row)
                    With ColumnChart
                        .ChartWizard(Source:=ColumnChartSourceRange, Title:="Purchases - " + TextPeriod1Name + " vs " + TextPeriod2Name, PlotBy:=Microsoft.Office.Interop.Excel.XlRowCol.xlColumns)
                        .ApplyLayout(9, Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered)
                        .ChartStyle = 34
                        .ApplyDataLabels(Microsoft.Office.Interop.Excel.XlDataLabelsType.xlDataLabelsShowLabel, False, False, False, False, False, True)
                        .SeriesCollection(1).DataLabels.Position = Microsoft.Office.Interop.Excel.XlDataLabelPosition.xlLabelPositionOutsideEnd
                        .SeriesCollection(1).Interior.Color = RGB(132, 175, 104)
                        .SeriesCollection(2).DataLabels.Position = Microsoft.Office.Interop.Excel.XlDataLabelPosition.xlLabelPositionOutsideEnd
                        .SeriesCollection(2).Interior.Color = RGB(19, 46, 66)
                        .PlotArea.Border.Weight = 1
                        .PlotArea.Border.Weight = 1
                        .PlotArea.Border.Color = ColorTranslator.ToOle(Color.Gray)
                        .ChartArea.Width = 563.04
                        .ChartArea.Height = 311.76
                        .ChartArea.Border.Weight = 1
                        .ChartArea.Border.LineStyle = 0
                        .Axes(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).HasTitle = True
                        .Axes(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).AxisTitle.Characters.Text = ""
                        .Axes(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).HasTitle = True
                        .Axes(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).AxisTitle.Characters.Text = ""
                        .Axes(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).TickLabels.NumberFormat = "$#,##0"
                        .Axes(Excel.XlAxisType.xlValue).MinimumScaleIsAuto = False
                        .Axes(Excel.XlAxisType.xlValue).MinimumScale = 0
                        .ChartArea.Format.TextFrame2.TextRange.Font.Size = 12
                        .Legend.Format.TextFrame2.TextRange.Font.Size = 12
                        .ChartArea.Format.TextFrame2.TextRange.Font.Bold = Microsoft.Office.Core.MsoTriState.msoTrue
                        .Legend.Format.TextFrame2.TextRange.Font.Bold = Microsoft.Office.Core.MsoTriState.msoTrue

我试图隐藏标有椭圆形的文字,但我无法。请让我知道隐藏该文字的设置。我试图将Axix Text设置为空,但不能正常工作。 enter image description here

0 个答案:

没有答案