简体   繁体   中英

Run Excel VBA code using PHP

I created Excel VBA code to create images from the corresponding URLs.

How can I write this code while creating the Excel file using PHP?

Sub RetrieveImage()

    Dim url_column As Range
    Dim image_column As Range

    Set url_column = Worksheets(1).UsedRange.Columns("D")
    Set image_column = Worksheets(1).UsedRange.Columns("J")

    Dim i As Long
    For i = 2 To url_column.Cells.Count

      With image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value)
        .Left = image_column.Cells(i).Left
        .Top = image_column.Cells(i).Top
        image_column.Cells(i).EntireRow.RowHeight = .Height
      End With

    Next

End Sub

You need only for this example or for all many macros ?

If only for this one: Use GD Library to generate image in PHP

If you want to convert macros to php code - that is almost impossible. You will need to write parser, which will translate macro code to php code...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM