php - 如何从 excel 文件中加载数据然后在 Laravel 中提交?
问题描述
我希望我的用户将带有 excel 文件的产品上传到固定类别。为此,我必须使用 excel 文件的值插入一些输入字段值。我的上传表单 HTML 是:
<form action="">
<input type="file" name="excel">
<button id="">Load Excel File</button>
</form>
<form action="{{ route('product.store') }}" method="POST" enctype="multipart/form-data">
@csrf
<input type="hidden" value="25">
<label for="">Price</label>
<input type="text" placeholder="Product Price">
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Action</th>
</tr>
@foreach()
<tr>
<td>{{ Name }}</td>
<td>{{ Email }}</td>
<td>{{ Phone }}</td>
<td>
<a href="">Remove</a>
</td>
</tr>
@endforeach
</table>
<button type="submit">Submit</button>
</form>
在这里,每个产品的 category_id 都是相同的。然后单价将由用户给出。然后选择excel文件。然后单击加载 excel 文件按钮。它将从 excel 文件中读取数据并将其显示在表格中。同时会匹配表头和excel文件头列。这里将只显示匹配头数据。然后用户可以检查数据。如果想要用户可以删除数据。然后提交按钮将在匹配的数据库列中为每个表列插入一行到数据库中。
我的问题是: 如何读取 excel 文件并在表格中显示数据并从表格中删除数据?是否可以使用 AJAX 或其他方式?
解决方案
推荐阅读
- 4d-database - 在 4D Write Pro (4D v17 R5) 中以编程方式设置文本样式
- azure-machine-learning-service - 将环境类与管道运行一起使用
- powerapps - PowerApps 修补集合中的数据源
- laravel - laravel 中的未来日期检查
- python - 在主 NameError 中:未定义名称“”
- eclipse - 如何在 Eclipse 中创建一个新的 ABAP 项目?
- sql - SQL 查询没有返回我所期望的
- python - 为什么它不应该返回这个命令?“numpy.ufunc”对象不可下标
- scheme - 在 Scheme 中 foldr 和 apply 有什么区别?
- python - 尝试检查另一个熊猫列中是否存在值时出现长度错误