我最近更改了一些代码,但是,我确保更改了范围。我遇到的问题是,即使我的代码显示为.HasTitle = False
,我创建并放入其自己的工作表的图表也是True
。当我将鼠标悬停在True上时,它会显示True = True
。我将提供我的代码和部分受影响区域和图表的屏幕截图。
Dim Histo As Chart, d As Worksheet
Set d = Worksheets("Data")
Application.Run "ATPVBAEN.XLAM!Histogram", d.Range("D2", d.Range("D2").End(xlDown)) _
, d.Range("G1"), d.Range("F2", d.Range("F2").End(xlDown)), False, False _
, False, False
Set Histo = Charts.Add
With Histo
.SetSourceData Source:=d.Range("G2", d.Range("H2").End(xlDown))
.ChartType = xlColumnClustered
.HasTitle = True
.ChartTitle.Text = "Cancelation Distribution by Year"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Total Years of Contract"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "# of Contracts Canceled"
.Location Where:=xlLocationAsNewSheet, Name:="Graph"
End With
提前致谢!
答案 0 :(得分:1)
尝试在.HasTitle = True
之前加 public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
。我认为在你的版本中,当你试图给它一个标题时,excel仍然试图弄清楚图表应该去哪里(所以图表还不存在)。