excel - 导出/导入代码后图表不会刷新
问题描述
使用这些代码图表显示没有问题:
Sub graphit()
On Error Resume Next
Set CurrentChart = ActiveSheet.ChartObjects("spectralcht")
On Error GoTo 0
If IsEmpty(CurrentChart) Then
' init chart if first run
Set speccht = ActiveSheet.ChartObjects.Add(Left:=100, Width:=500, Top:=100, Height:=300)
chtcount = ActiveSheet.ChartObjects.Count
Set speccht = ActiveSheet.ChartObjects(chtcount)
speccht.Name = "spectralcht"
With speccht.Chart
.ChartType = xlXYScatterLinesNoMarkers 'Ensure chart has a title
.HasTitle = True
.ChartTitle.Text = "Spectrum (power vs Wavelength)"
.Legend.Delete
.Axes(xlValue).MinimumScale = 0
.Axes(xlValue).MaximumScale = 4000
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "WaveLength (nm)"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Intencity"
.Axes(xlCategory, xlPrimary).HasMajorGridlines = True
.Axes(xlCategory, xlPrimary).HasMinorGridlines = True
.Axes(xlCategory, xlPrimary).MajorGridlines.Border.Color = RGB(0, 0, 255)
.Axes(xlCategory, xlPrimary).MajorGridlines.Border.LineStyle = xlDash
End With
End If
'chage axe for new WL
Set speccht = ActiveSheet.ChartObjects("spectralcht")
With speccht.Chart
.Axes(xlCategory).MinimumScale = CDbl(MinWL.Value)
.Axes(xlCategory).MaximumScale = CDbl(MaxWL.Value)
End With
' plot graph
With speccht.Chart.SeriesCollection
If .Count = 0 Then .NewSeries
.Item(1).Values = Spectrum()
.Item(1).XValues = Wavelengths()
End With
End Sub
但是,如果我将表格导出并导入另一本书,它将不会显示数据!它显示图表,轴,但没有数据没有图表。在这一点上我有点失落谢谢提前拍
解决方案
推荐阅读
- httprequest - 如何删除 chrome 的 arc(高级 REST 客户端)扩展中保存的请求?
- go - Golang 中处理多个错误的最佳实践
- c# - 自定义用户身份验证 ASP.net MVC 在服务器上不起作用
- jquery - 如何使用 jQuery AJAX 更新 ASP.NET MVC 视图数据?
- regex - 正则表达式找到一个双字母的多个实例?
- php - 如何在 ajax 回调函数中的 wordpress 中使用 Dompdf
- java - 在 jaxb 编组期间创建的重复元素
- rest - 空结果 204 或 404 的请求中的 HTTP 返回代码是什么?
- jquery - 使用 jQuery slideDown 或 toggleClass 和 css 过渡添加向下滑动效果
- json - 带有可选成员的 Kotlin 类