我需要一些帮助,这个HTTP请求失败错误给了我很多头疼。我尝试在本地服务器和在线服务器,但它仍然无法正常工作,我试图将我的表数据导出为.PDF或.XLS格式。这是我的控制者。
public function export()
{
$format = Input::query('type');
$filename = Carbon::now()->format('Ymd_') . "ProductsList";
$file = Excel::create($filename, function ($excel) {
$excel->sheet('Product Cost and Amount', function ($sheet) {
$sheet->setfitToPage(0);
$sheet->setfitToWidth(0);
$sheet->setfitToHeight(0);
$sheet->freezeFirstRowAndColumn();
$sheet->setOrientation('landscape');
$products = $this->report->getProductLevels();
$sheet->loadView('reports.product_report.product_level_report', compact('products'));
});
$excel->sheet('Product Locations', function ($sheet) {
$sheet->setfitToPage(0);
$sheet->setfitToWidth(0);
$sheet->setfitToHeight(0);
$sheet->freezeFirstRowAndColumn();
$products = $this->report->getProductLevels();
$sheet->loadView('reports.product_report.product_warehouse_level', compact('products'));
});
});
我的观点
<html>
{{ HTML::style('dist/css/table.css') }}
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<body>
<!-- Headings -->
<thead>
<tr>
<th>#</th>
<th>Product Name</th>
<th>Amount</th>
<th>Reorder Amount</th>
<th>Unit Cost</th>
<th>Selling Cost</th>
<th>Tax rate</th>
<th>Category</th>
</tr>
</thead>
<?php $i = 1; ?>
@foreach($products as $product)
<tr>
<td scope="row">{{$i}}</td>
<td><b>{{$product->productName}}</b></td>
<td>{{$product->amount}}</td>
<td>{{$product->reorderAmount}}</td>
<td>{{$product->unitCost}}</td>
<td>{{$product->sellingCost}}</td>
<td>{{$product->productTaxRate}}%</td>
<td>{{$product->categoryName}}</td>
</tr>
<?php $i++; ?>
@endforeach
</body>
</html>
我在几个小时内就坚持了下来,仍然无法解决这个问题。如果有人愿意帮助我,我很高兴,谢谢你的关注