可以通过宏来实现:先按你的需求调整一张图片,并将此过程录制为一个宏,然后将其余图表应用此宏,即可实现所有图表的格式与第一张图保持统一。下面以Excel 2010为例进行演示:
1、初始数据及图表样式,显然格式不统一
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/024f78f0f736afc3c2113d72b519ebc4b7451283?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
2、如下图创建宏,在弹出菜单中设置宏名(例如chart_style)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/c9fcc3cec3fdfc031d6ee1afd23f8794a4c22696?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
3、在新弹出的Visual Basic窗口中,添加如下代码。可以根据注释,修改为需要的样式。
Sub chart_style()
'设置图表区域的宽度和高度
ActiveChart.ChartArea.Select
Selection.Width = 230
Selection.Height = 160
'设置绘图区域的大小
ActiveChart.PlotArea.Select
Selection.Top = 0
Selection.Left = 10
Selection.Height = 150
Selection.Width = 210
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
End With
' 设置x轴的字体、大小、粗细
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
ActiveChart.Axes(xlCategory).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
End With
ActiveChart.Axes(xlCategory).AxisTitle.Select
With Selection.Format.TextFrame2.TextRange.Font
.NameComplexScript = "Times New Roman"
.NameFarEast = "Times New Roman"
.Name = "Times New Roman"
.Bold = msoFalse
.Size = 13
End With
' 设置y轴的字体、大小、粗细
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated)
ActiveChart.Axes(xlValue).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
End With
ActiveChart.Axes(xlValue).AxisTitle.Select
With Selection.Format.TextFrame2.TextRange.Font
.NameComplexScript = "Times New Roman"
.NameFarEast = "Times New Roman"
.Name = "Times New Roman"
.Bold = msoFalse
.Size = 13
End With
End Sub
4、选中一个图表,点击菜单的“宏”,在弹出窗口中,点击执行;同样设置另一幅图。
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/9358d109b3de9c82b6adf6986a81800a18d843d8?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
5、最终实现效果统一如下
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/0b46f21fbe096b63f08951470a338744ebf8ac10?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)