Jump to content

Recommended Posts

Dears ,

I have an issue running VBScript to convert csv to xlsx and apply formatting on it from PHP where WorkBook (WB) variable always is empty.

VBScript file works fine from command line , Apache service running as Administrator.

I use XAMPP 7.4.21 on windows 2016

VBScript Code:

Dim file, WB

With CreateObject("Excel.Application")

On Error Resume Next

For Each file In WScript.Arguments

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set stdout = objFSO.GetStandardStream (1)

Set stderr = objFSO.GetStandardStream (2)

src_file = objFSO.GetAbsolutePathName(file)

stdout.WriteLine src_file

Set WB = .Workbooks.Open(src_file)

if IsEmpty(WB) Then

            stdout.WriteLine "Yes"

Else

            stdout.WriteLine "No"

End If

WB.Worksheets(1).Range("A1:H1").Interior.ColorIndex = 29

WB.Worksheets(1).Range("A1:H1").Font.ColorIndex = 2

WB.Worksheets(1).Range("A1:H1").Font.Bold = True

WB.Worksheets(1).Range("A1:H1").Font.Size = 14

WB.SaveAs Replace(objFSO.GetAbsolutePathName(WB.FullName), ".csv", ".xlsx"), 51

WB.Close False

Next

.Quit

End With

PHP call :


exec("cscript.exe csvToxlsx.vbs sector_19_Buildings.csv");

 

Edited by Mohands
Link to comment
https://forums.phpfreaks.com/topic/313643-run-vbscript-from-php-issue/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.