我有一个代码可以创建我的表的.csv
导出。这是我的代码:
public function export(Request $request){
header('Content-Type: application/excel');
header('Content-Disposition: attachment; filename="export.csv"');
$tb_name_alias = $request->tb_name;
$convert_alias_to_table_name = array('person' => "App\\persons");
$tb_name = $convert_alias_to_table_name[$tb_name_alias];
$arr = $tb_name::all()->toArray();
$newarr = array();
$size_of_outer_array = sizeof($arr);
For ( $i = 0; $i < $size_of_outer_array; $i++ ) {
$newarr[] = implode(",",$arr[$i]);
}
$fp = fopen('php://output', 'w');
foreach ( $newarr as $line ) {
$val = explode(",", $line);
fputcsv($fp, $val);
}
fclose($fp);
}
它也可以,但是当我再次导入它时,它看起来像这样:
如您所见,列名称并非真实......它们是col1
,col2
等等。但是我需要设置一些名称作为列名。与id
,name
等类似。!
我该怎么做?
答案 0 :(得分:1)
试试这个
HWND hwndWBA;
pwba->get_HWND((LONG_PTR*)&hwndWBA);
InvalidateRect(hwndWBA, NULL, TRUE);
pwba->Quit();
pwba->Release();