欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php excel,该如何处理

程序员文章站 2024-01-31 17:39:58
...
php excel
error_reporting(E_ALL);
date_default_timezone_set('Europe/London');
/** PHPExcel */
require_once '../Classes/PHPExcel.php';

// Create new PHPExcel object
$objPHPExcel = new PHPExcel();

// Set properties
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
->setSubject("Office 2007 XLSX Test Document")
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
->setKeywords("office 2007 openxml php")
->setCategory("Test result file");
$objPHPExcel->getActiveSheet()->mergeCells('A1:G1');
$objPHPExcel->getActiveSheet()->mergeCells('H1:W1');
$objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('H1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);

// Add some data


$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'user-data')
->setCellValue('A2', 'username')
->setCellValue('B2', 'password')
->setCellValue('C2', 'sex')
->setCellValue('D2', 'grade')
->setCellValue('E2', 'age')
->setCellValue('F2', 'weight')
->setCellValue('G2', 'height')
->setCellValue('H1', 'Module1')
->setCellValue('I2', 'Q2')
->setCellValue('J2', 'Q3')
->setCellValue('K2', 'Q4')
->setCellValue('L2', 'Q5')
->setCellValue('M2', 'Q6')
->setCellValue('N2', 'Q7')
->setCellValue('O2', 'Q2')
->setCellValue('P2', 'Q3')
->setCellValue('Q2', 'Q4')
->setCellValue('R2', 'Q5')
->setCellValue('S2', 'Q6')
->setCellValue('T2', 'Q7')
->setCellValue('U2', 'Q2')
->setCellValue('V2', 'Q3')
->setCellValue('W2', 'Q4')
->setCellValue('X1', 'Module2')
->setCellValue('Y2', 'Q1')
->setCellValue('Z2', 'Q2');

//数据库连接
$db = mysql_connect("localhost", "root", "");
mysql_select_db("test",$db); //选择数据库,这里为"ywcl"。
mysql_query("SET NAMES UTF8"); //设定编码方式为UTF8

$sqlgroups="select * from user order by username";
$resultgroups=mysql_query($sqlgroups);
php excel,该如何处理

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频