Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

header export excel data only php

1 /**
 2  * Export data to excel
 3  *@param $data    A two-dimensional array, the structure of which is similar to the array found from the database
 4  *@param $title   excel The first row title of, an array, if empty, no title
 5  *@param $filename Downloaded file name
 6  *@examlpe10  */
11 function exportexcel($data=array(),$title=array(),$filename='report'){
12     ob_end_clean(); 
13     ob_start(); 
14     header("Content-type:application/octet-stream");
15     header("Accept-Ranges:bytes");
16     header("Content-type:application/vnd.ms-excel");
17     header("Content-Disposition:attachment;filename=".$filename.".xls");
18     header("Pragma: no-cache");
19     header("Expires: 0");
20     //export xls start
21     if (!empty($title)){
22         foreach ($title as $k => $v) {
23             $title[$k]=iconv("UTF-8", "GB2312",$v);
24         }
25         $title= implode("	", $title);
26         echo "$title
";
27     }
28     if (!empty($data)){
29         foreach($data as $key=>$val){
30             foreach ($val as $ck => $cv) {
31                 $data[$key][$ck]=iconv("UTF-8", "GB2312", $cv);
32             }
33             $data[$key]=implode("	", $data[$key]);
34         }
35         echo implode("
",$data);
36     }
37 }
Comment

PREVIOUS NEXT
Code Example
Csharp :: cannot convert string to generic type c# 
Csharp :: git find commits by message 
Csharp :: this in unity 
Csharp :: how to get hours and minutes from second in c# 
Csharp :: c# file directory selection 
Csharp :: instantiate list c# 
Csharp :: Open another form with C# Winforms 
Csharp :: list all files in directory and subdirectories c# 
Csharp :: c# find element by condition 
Csharp :: c# console save file 
Csharp :: scaffold single table to model ef core 
Csharp :: unity always rotating object 
Csharp :: .net c# print object 
Csharp :: c# encode jpg hiight quality 
Csharp :: get last element in a list vb.net 
Csharp :: What is the difference between String and string in C#? 
Csharp :: unity instantiate prefab rotation 
Csharp :: Install Mono project on Ubuntu 20.04 
Csharp :: nested dictionary c# 
Csharp :: add all elements in a list c# 
Csharp :: how to create a delegate in c# 
Csharp :: linear search c# 
Csharp :: color unity 
Csharp :: CS0101 Unity Error Code 
Csharp :: get text unity 
Csharp :: c# get application root path directory 
Csharp :: wpf arrow button 
Csharp :: c# escape characters 
Csharp :: asp.net core mvc jsonresult example 
Csharp :: unity call function on update once per second 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =