I have an existing excel file. i want to add data in this using my website.
我有一个现有的excel文件。我想用我的网站添加数据。
Read/Write/Update Query
读/写/更新查询
Help Me.
帮我。
1 个解决方案
#1
0
Assuming you're using PHPExcel you would do this to write a single row:
假设您正在使用PHPExcel,您可以这样写一行:
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$row = 1;
$objPHPExcel->getActiveSheet()->SetCellValue('A'.$row, $_POST['name']);
$objPHPExcel->getActiveSheet()->SetCellValue('B'.$row, $_POST['email']);
$objPHPExcel->getActiveSheet()->SetCellValue('C'.$row, $_POST['phone']);
$objPHPExcel->getActiveSheet()->SetCellValue('D'.$row, $_POST['adress']);
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('myfile.xlsx');
Reading files involves starting here and working forward:
阅读文件涉及从这里开始并向前发展:
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$data = $objReader->load('myfile.xlsx');
$objWorksheet = $data->getActiveSheet();
Obviously you'll need to do more digging into the docs to learn how to open existing files and append to them, but that hopefully gives you a kick in the right direction.
显然,你需要更多地深入研究文档以学习如何打开现有文件并附加到它们,但这有望为你提供正确的方向。
#1
0
Assuming you're using PHPExcel you would do this to write a single row:
假设您正在使用PHPExcel,您可以这样写一行:
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$row = 1;
$objPHPExcel->getActiveSheet()->SetCellValue('A'.$row, $_POST['name']);
$objPHPExcel->getActiveSheet()->SetCellValue('B'.$row, $_POST['email']);
$objPHPExcel->getActiveSheet()->SetCellValue('C'.$row, $_POST['phone']);
$objPHPExcel->getActiveSheet()->SetCellValue('D'.$row, $_POST['adress']);
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('myfile.xlsx');
Reading files involves starting here and working forward:
阅读文件涉及从这里开始并向前发展:
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$data = $objReader->load('myfile.xlsx');
$objWorksheet = $data->getActiveSheet();
Obviously you'll need to do more digging into the docs to learn how to open existing files and append to them, but that hopefully gives you a kick in the right direction.
显然,你需要更多地深入研究文档以学习如何打开现有文件并附加到它们,但这有望为你提供正确的方向。