-1

我想知道是否可以自动从多个 exel 文件中提取数据,绘制图表并最终使用预先存在的模板在 pointpoint 中呈现数据。我尝试了 Python,但可以走得更远,现在有人建议使用 VB。我将非常感谢您的帮助。这是我的数据库看起来像

  1. 多个目录包含以下样式名称的excel文件 dir_1/paint_for_yard1/Blue_light_b2.xls dir_1/paint_for_yard1/Red_light_b3.xls dir_1/pat_for_yard8/Green_light_b2.xls 每个目录下有多个文件,包含三列中的许多数据(pigment-color ,白天运行时间,夜间运行时间)
  2. 我有一个 power-point 模板,需要根据以下格式的 excel 文件中的数据进行更新第二页(在封面页之后)应该在标题 paint_for_yard1 中包含以下内容:Blue_light

    在页面正文中:当 day_run_time 最小时,有一个表格给出了最大 day_run_time 和颜料颜色)。然后在同一页面中创建颜料颜色、日间运行时间、夜间运行时间的图表。

  3. 对每个文件执行第 2 步并在 power-point 中添加页面。

由于我不是软件专家,我不确定 Python 或 VB 或组合是否会对我有所帮助。任何建议将不胜感激。

谢谢阿尼尔

4

2 回答 2

1

几乎任何“成长”的编程语言都可以做到这一点。所以... C# / VB.NET / Python 可以为你解决这个问题。

我想我会在 PowerPoint 模板中使用 VBA 脚本。VBA 是专门为 Office 制作的,它可以与 Excel 进行通信。

于 2013-04-29T15:57:11.433 回答
0

我使用 follow Sub 从 Excel 文件创建一个 PowerPoint 演示文稿。

Sub Gera_PPT(PFile As String, EFile As String, Plans As Collection)
'officevb.com
'PFile= PowerPoint Template empty powerPoint with Slide Master to presentation
'EFile = Excel File with Charts and Tables
'Plans = A collection with names of sheets to transpose
Dim rg As Range
'objetos usados para o powerpoint
Dim pptA As Object
Dim ppt As Object
Dim sld As Object

Debug.Print "passei 1"


If Not ValidaCaminho(PFile) Then
    MsgBox "PowerPoint file not found!", vbInformation
    Exit Sub
Else
    Set pptA = CreateObject("PowerPoint.Application")
    pptA.Visible = msoCTrue
    'pptA.WindowState = -1
    Set ppt = pptA.Presentations.Open(PFile)
End If

'objetos usados para o Excel
Dim ExA As Excel.Application
Dim wb As Excel.Workbook
Dim sht As Excel.Worksheet


If Not ValidaCaminho(EFile) Then
    MsgBox "Excel file not found!!", vbInformation
    Exit Sub
Else
    Set ExA = New Excel.Application
    'ExA.Visible = True
    Set wb = Workbooks.Open(EFile, False)
End If

Debug.Print "passei 2"

'For Each sht In wb.Sheets
For i = 1 To Plans.Count

Set sht = wb.Sheets(Plans(i))

    Select Case Left(sht.Name, 1)

    'Debug.Print "passei 3"
    'case is Table
    Case "T"
           Set sld = ppt.Slides.AddSlide(ppt.Slides.Count + 1, ppt.SlideMaster.CustomLayouts(2))
           sld.Select
           sld.Shapes.Placeholders(2).Select msoCTrue

           Set rg = sht.Range("B4").CurrentRegion
           rg.Copy
           ppt.Windows(1).View.PasteSpecial ppPasteMetafilePicture

    Case "G"
    'Case is 1 Chart

        If sht.ChartObjects.Count = 1 Then

              Set sld = ppt.Slides.AddSlide(ppt.Slides.Count + 1, ppt.SlideMaster.CustomLayouts(2))
              sld.Select
              sld.Shapes.Placeholders(2).Select msoCTrue

              sht.ChartObjects(1).Copy

              ppt.Windows(1).View.PasteSpecial ppPasteMetafilePicture

'              sld.Shapes.Placeholders.Item(1).TextFrame.TextRange.Text = sht.[A2]
        Else
        'Case is >1 Chart
              Set sld = ppt.Slides.AddSlide(ppt.Slides.Count + 1, ppt.SlideMaster.CustomLayouts(4))
              sld.Select

              sht.Activate

              sld.Shapes.Placeholders(1).TextFrame.TextRange.Text = sht.Range("A2").Value

              sld.Shapes.Placeholders(2).Select msoCTrue
              sht.ChartObjects(1).Copy
              ppt.Windows(1).View.PasteSpecial ppPasteMetafilePicture

              sld.Shapes.Placeholders(3).Select msoCTrue
              sht.ChartObjects(2).Copy
              ppt.Windows(1).View.PasteSpecial ppPasteMetafilePicture

        End If

    End Select

Next i

'Insert LastSlide
Set sld = ppt.Slides.AddSlide(ppt.Slides.Count + 1, ppt.SlideMaster.CustomLayouts(5))

wb.Close False
ExA.Quit

Strfile = Split(apoio.[PPTFile], "\")

ppt.SaveAs YourFilePath & "\" & Split(Strfile(UBound(Strfile)), ".")(0) & "-" & Format(Date, "ddmmyyyy")

pptA.Quit

MsgBox "Presentation created!", vbInformation

End Sub
于 2013-04-29T16:25:02.620 回答