您好,我正在与simplexlxs一起使用excel文件更新数据库,该文件具有4813行,但只有insertme 3122行,而不是4813行,我尝试使用只有5行的文件,没有问题,任何想法都在发生吗?,即时通讯使用mysqli在php文件和数据库之间建立连接,在这里留下了代码
<?php
if (isset($_FILES['file'])) {
require_once __DIR__ . '/simplexlsx.class.php';
if ( $xlsx = SimpleXLSX::parse( $_FILES['file']['tmp_name'] ) ) {
$total = $mysqli -> query("DELETE FROM procura");
foreach ( $xlsx->rows() as $k => $Row) {
if($k== 0){ continue; }
for ( $i = 0; $i < 1 ; $i ++ ) {
$item = isset($Row[0]) ? $Row[0] : '';
$codsap = isset($Row[1]) ? $Row[1] : '';
$desc = isset($Row[2]) ? $Row[2] : '';
$und = isset($Row[3]) ? $Row[3] : '';
$menor = isset($Row[4]) ? $Row[4] : '';
$peso = isset($Row[5]) ? $Row[5] : '';
$volumen = isset($Row[6]) ? $Row[6] : '';
$provme = isset($Row[7]) ? $Row[7] : '';
$provpis = isset($Row[8]) ? $Row[8] : '';
$proceso = isset($Row[9]) ? $Row[9] : '';
$econcur = isset($Row[10]) ? $Row[10] : '';
$econtr = isset($Row[11]) ? $Row[11] : '';
$fecha = isset($Row[12]) ? $Row[12] : '';
$query = "insert into procura(item, codigo_sap, descripcion, und, menor_precio, peso, volumen, provmenor, paisprov, nproceso, empresacon, econtra, fecha) values('".$item."','".$codsap."','".$desc."','".$und."','".$menor."','".$peso."','".$volumen."','".$provme."','".$provpis."','".$proceso."','".$econcur."','".$econtr."','".$fecha."')";
$mysqli->query($query);
}
}
echo' <script type="text/javascript">
alert("Base de Datos subida con exito");
window.location.href = "index.php";
</script>';
} else {
echo SimpleXLSX::parse_error();
}
}?>
<div class="row">
<div class="panel panel-default">
<div class="panel-heading">
<h1>Actualice su base de datos</h1>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
<h2>Seleccionar archivo de excel</h2>
</div>
<div class="col-md-6">
<form method="post" enctype="multipart/form-data">
<label>*.XLSX </label>
<input type="file" name="file" class="pad" />
<input type="submit" value="Subir" />
</form>
</div>
</div>
</div>
</div>