Paul's Programming Notes     Archive     Feed     Github

PHP - Verify File Is Uploaded And Zip


if($_FILES["zip_file"]["name"]) {
     $filename = $_FILES["zip_file"]["name"];


     $name = explode(".", $filename);


     $continue = strtolower(end($name)) == 'zip' ? true : false;
     if(!$continue) {
           $message = "The file you are trying to upload is not a .zip file. Please try again.";
     } else {
          $message = "File Is .zip";
     }
}

PHP - Loop Through Excel Document and Print Cells


require_once 'excel_reader2.php';

foreach($reader->sheets as $k=>$data)
 {
    echo "\n\n ".$reader->boundsheets[$k]."\n\n";

    foreach($data['cells'] as $row)
    {
        foreach($row as $cell)
        {
            echo "$cell\t";
        }
        echo "\n";
    }
 }

Check If Workbook Is Open By Name - VBA

This code from StackOverflow helped me find whether a workbook was open with its name. Here's the link to the thread: Link

Function BookOpen(strBookName As String) As Boolean
    Dim oBk As Workbook
    On Error Resume Next
    Set oBk = Workbooks(strBookName)
    On Error GoTo 0
    If oBk Is Nothing Then
        BookOpen = False
    Else
        BookOpen = True
    End If
End Function

Sub testbook()
    Dim strBookName As String
    strBookName = "myWork.xls"
    If BookOpen(strBookName) Then
        MsgBox strBookName & " is open", vbOKOnly + vbInformation
    Else
        MsgBox strBookName & " is NOT open", vbOKOnly + vbExclamation
    End If
End Sub