- 积分
- 106
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-4-29
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 xyangtian 于 2017-6-18 19:07 编辑
- Imports Microsoft.Win32
- Class MainWindow
- Dim ArrFile() As String
- Dim ListFile As New List(Of String)
- Dim ListName As New List(Of String)
- Dim BaseFolder As String
- Private Sub button_Click(sender As Object, e As RoutedEventArgs)
- Dim dlg As New Microsoft.Win32.OpenFileDialog()
- dlg.FileName = "Document"
- dlg.DefaultExt = ".dat"
- dlg.Filter = "Text documents (.dat)|*.dat"
- dlg.Multiselect = True
- Dim result? As Boolean = dlg.ShowDialog()
- If result = True Then
- ArrFile = dlg.FileNames
- FileTb.Text = dlg.FileName
- For i = 0 To ArrFile.Length - 1
- BaseFolder = ArrFile(i).Remove(ArrFile(i).LastIndexOf("")) '获取文件路径
- ListFile.Add(ArrFile(i).Remove(ArrFile(i).LastIndexOf("."))) '移除文件名后缀
- ListName.Add(ArrFile(i).Substring(ArrFile(i).LastIndexOf("") + 1, (ArrFile(i).LastIndexOf(".") - ArrFile(i).LastIndexOf("") - 1))) '截取文件名
- Next
- End If
- End Sub
- Private Sub Scatter_Click(sender As Object, e As RoutedEventArgs)
- For i = 0 To ArrFile.Count() - 1
- Dim GrapherApp As Object
- GrapherApp = CreateObject("Grapher.Application") '创建Grapher实例
- GrapherApp.Visible = False
- Dim Docs As Object
- Docs = GrapherApp.Documents
- Dim Plot As Object
- Plot = Docs.Add()
- Dim Shapes As Object
- Shapes = Plot.Shapes
- Dim Graph As Object
- Graph = Shapes.AddLinePlotGraph(ArrFile(i), 2, 3)
- Dim Axes As Object
- Axes = Graph.Axes
- Dim XAxis As Object
- XAxis = Axes(1)
- XAxis.Scale = 2 '设置X轴为对数
- Dim XAxisTitle As Object
- XAxisTitle = XAxis.title
- XAxisTitle.Text = "1111" '设置X轴标题内容
- Dim YAxis As Object
- YAxis = Axes(2)
- YAxis.Scale = 2 '设置Y轴为对数
- Dim YAxisTitle As Object
- YAxisTitle = YAxis.title
- YAxisTitle.Text = "2222" '设置Y轴标题内容
- Dim GraphPlots As Object
- GraphPlots = Graph.Plots(1)
- Dim GraphTitle As Object
- GraphTitle = Graph.Title
- GraphTitle.Text = "nihao" '设置标题内容
- Dim GraphLine As Object
- GraphLine = GraphTitle.line '选取标题的线属性
- GraphLine.Style = "Invisible" '设置线属性
- Dim GraphSymbol As Object
- GraphSymbol = Graph.Plots.Item(1)
- GraphSymbol.symbolFreq = 1 '设置标记个数
- Dim GraphColor As Object
- GraphColor = GraphSymbol.Symbol
- GraphColor.Fill.ForeColor = 100 '设置标记填充颜色
- Plot.SaveAs(BaseFolder + "" + ListName(i) + "grf")
- GrapherApp.Quit()
- System.GC.Collect(System.GC.GetGeneration(GrapherApp))
- Next
- MsgBox("OK")
- End Sub
- End Class
复制代码 vb.net,你可以把它转成vb。grapher一定要是英文版,汉化版会有各种错误。
|
|