dsh1956 2017-08-18 20:31
浏览 72

XLSB通过PHP发送CSV错误

I am having trouble find the problem with the php script that supposed to convert the XLSB file to CSV. For some reason, it's throwing this parse error. I tried looking at the code but I don't understand what I did wrong.

I encountered the following error:

Parse error: syntax error, unexpected end of file in /storage/ssd3/577/2617577/public_html/XLSB2CSV/XLSB2CSV/index.php on line 163

I posted the index.php and shared the files through ge.tt website, which is http://ge.tt/7k7vZDm2

Index

<?php 


$result=0;
if (isset($_POST["convert"])) { 
   $filetoname = basename($_FILES['xlsbfile']['name']); 
   if($filetoname==""){$alert = "Select a file";}else{
   $ext = substr($filetoname,-4);
   if($ext!="xlsb"){$alert = "Invalid file type. Select an .xlsb file.";}else{
    $throttle=0;
    //$throttle=preg_replace("/[^0-9]/","",$throttle);
   $result = @move_uploaded_file($_FILES['xlsbfile']['tmp_name'], $filetoname); // upload it 
    $file=$filetoname;
    $throttle=0;

//Code for reading xlsb file
$workbook = new COM("EasyXLS.ExcelDocument");
$workbook->easy_LoadXLSBFile($file);

//Code for converting to CSV
$workbook->easy_WriteCSVFile("file.csv", $workbook->easy_getSheetAt(0)->getSheetName());


if(isset($_GET[$workbook]){  $csvFile = $workbook;
$alert = "Your download will start in <span id='timer'>5</span>
 seconds<br/>or click <a href=$csvFile>this link</a> to start download now:";
 $redir= '<meta http-equiv="refresh" content="5;url=index.php?file='.$csvFile.'">'; };

 echo '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <title>XLSB TO CSV Web application</title>
        <meta http-equiv="CACHE-CONTROL" content="NO-CACHE"/>
        <meta http-equiv="PRAGMA" content="NO-CACHE"/>
        <meta http-equiv="EXPIRES" content="0"/>
        <meta content="NONE" name="ROBOTS"/>
        <meta content="JavaScript" name="vs_defaultClientScript"/>
        <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"/>
        <link href="style_new.css" type="text/css" rel="stylesheet"/>
        <script language="javascript" src="_js/jsCommon.js" type="text/javascript"></script>
        <script language="javascript" type="text/javascript">
            /*if(document.location.href.indexOf(\'https\')>-1){
                document.location = document.location.href.replace(\'https\', \'http\');
            }*/

            function findPosX(obj){
                var curleft = 0;
                if (obj.offsetParent){
                    while (obj.offsetParent){
                        curleft += obj.offsetLeft;
                        obj = obj.offsetParent;
                    }
                }else if (obj.x)
                    curleft += obj.x;
                return curleft;
            }

            function findPosY(obj){
                var curtop = 0;
                if (obj.offsetParent){
                    while (obj.offsetParent){
                        curtop += obj.offsetTop;
                        obj = obj.offsetParent;
                    }
                }else if (obj.y)
                    curtop += obj.y;
                return curtop;
            }

            function showTooltip(objDiv, strMessage, e){
                getID(\'divToolti\').style.display = \'block\';
                getID(\'divTooltip\').innerHTML = strMessage;

                objDiv.onmousemove = function(e){
                    if(typeof e==\'undefined\')
                        e = window.event;

                    getID(\'divTooltip\').style.left = e.clientX - (getID(\'divTooltip\').offsetWidth / 2);
                    getID(\'divTooltip\').style.top = e.clientY + 20 + document.body.scrollTop;
                }
            }

            function hideTooltip(objDiv){
                getID(\'divTooltip\').style.display = \'none\';
                getID(\'divTooltip\').style.left = -200;
                getID(\'divTooltip\').style.top = -50;
                objDiv.onmousemove = null;
            }
        </script>
    </head>
    <body>
        <div class="clsPanelText" id="divTooltip" style="border-right:#666 1px solid;padding-right:4px;border-top:#666 1px solid;display:none;padding-left:4px;padding-bottom:4px;border-left:#666 1px solid;padding-top:4px;border-bottom:#666 1px solid;position:absolute;background-color:#fff"></div>
        <form name="Form1" method="post" action="index.php" id="Form1" enctype="multipart/form-data">
            <table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">
                <tr valign="middle">
                    <td align="center">
                            <div id="pnlDemoFirstStep" style="text-align:center;">

                                <table class="clsPanelText" cellspacing="0" cellpadding="0" width="900" align="center" style="position:relative;top:10px" border="0">
                                    <tr>
                                        <td>
                                            <div class="clsH3" align="middle">
                                                XLSB TO CSV Converter Web Application
                                            </div><br/><br/>
                                            <br/>
                                            <span class="clsH3">Step One:</span> 
                                        Please select the Excel file you saved on your local hard 
                                        drive with your data and convert it back into downloadbale CSV into this website.<br/>
                                        </td>
                                    </tr>
                                    <tr>
                                    <td style="padding-left:140px"><br/>
                                        <img style="vertical-align:middle" src="step1.jpg" alt="Step 3"/> 
                                        <b>Upload the Excel file</b><br/><br />
                                        <table class="clsPanelText" cellspacing="0" cellpadding="10" width="620" border="0" style="border:solid 1px #DDD;background-color:#eaf0f0">
                                            <tr>
                                                <td valign="bottom">
                                                    Upload the XLSB template:<br/>
                                                    <input type="hidden" name="convert">
                                                    <input name="xlsbfile" type="file" id="txtUploadTemplate" class="clsInputText6" oncontextmenu="this.blur();" onkeydown="this.blur();" style="width:390px;height:24px" size="61" />
                                                    <input type="submit" name="btnUploadXLS" value="Upload XLSB template" id="btnUploadXLS" class="clsButton1" onmouseover="this.style.backgroundColor=\'#80B3C4\'" onmouseout="this.style.backgroundColor=\'#22769D\'" style="width:170px;" />
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                </table>

                                <br/>

                                <table class="clsPanelText" cellspacing="0" cellpadding="0" width="900" align="center" style="position:relative;top:10px" border="0">
                                    <tbody>
                                    <tr>
                                        <td style="padding-left:140px"><br>
                                            <img style=" vertical-align:middle" src="step2.jpg" alt="Step 2"> 
                                            <b>Generate custom CSV file</b><br><br>
                                            <table class="clsPanelText" cellspacing="0" cellpadding="10" width="620" border="0" style="border:solid 1px #DDD;background-color:#eaf0f0">
                                                <tbody><tr>
                                                    <td>
                                                        $alert;
                                                    </td>
                                                </tr>
                                            </tbody></table>
                                        </td>
                                    </tr>
                                    <tr>

                                    </tr>
                                </tbody></table>
                        </div>
                    </td>
                </tr>
            </table>
        </form>
        <script language="javascript" type="text/javascript">
            window.history.forward();
        </script>
        <script language="javascript" src="_js/jsAnalytics.js" type="text/javascript"></script>
    </body>
</html>
';
?>
  • 写回答

1条回答 默认 最新

  • dongxie2613 2017-08-19 06:57
    关注

    You are missing a closing bracket here

     if(isset($_GET[$workbook])) //<--- this one
    
    评论

报告相同问题?

悬赏问题

  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝