PHP简单的Excel库 [英] PHP simple Excel lib

查看:84
本文介绍了PHP简单的Excel库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来执行以下操作:

I'm looking for a way to do the following:

$file = 'file.xls';
$input = '<tr><td>Some input</td></tr>';

if (!file_exists($file))
{
     create_excel($file);  //Create the sheet
     input_titles($file);  //Add column titles
}
else
{
     add_input_to_the_last_line($input);
}

有没有可以简单地做上述的图书馆?

Is there a library which can simply do the above?

推荐答案

您可以使用PHPExcel

You could use PHPExcel library:

$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$rowCount = 1;
while($row = mysql_fetch_array($result)){
    $objPHPExcel->getActiveSheet()->SetCellValue('A'.$rowCount, <your_row_name>);
    $objPHPExcel->getActiveSheet()->SetCellValue('B'.$rowCount, <your_row_name>);
    $rowCount++;
}
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('your_file_name.xlsx');

这篇关于PHP简单的Excel库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆