我在 MYSQL 中有一个如下所示的表(注意 html 代码):
===================================================================|
| Question | Answer |
=========+===========+=============================================|
| <p> Do you listen to music? </p> | YES |
|------------------------------------------------------------------|
| Who is your favorite music artists? | Justin Beiber |
|------------------------------------------------------------------|
|<script>Are you a Male or female?</script> | M |
|------------------------------------------------------------------|
我在 PHP 中使用 PHPExcel 来提取该数据并将其放入一个 excel 文件中,该表就是我的 excel 文件的样子。
在 excel 中,我希望删除 html,以便字段仅包含问题:
===================================================================|
| Question | Answer |
=========+===========+=============================================|
| Do you listen to music? | YES |
|------------------------------------------------------------------|
| Who is your favorite music artists? | Justin Beiber |
|------------------------------------------------------------------|
| Are you a Male or female? | M |
|------------------------------------------------------------------|
PHP中的代码:
$col=1; // 1-based index
while($row_data = mysql_fetch_assoc($result)) {
$row= 1;
foreach ($row_data as $key=>$value) {
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $value);
$row++;
}
$col++;
}
$row=1;
while($row_data = mysql_fetch_assoc($result2)) {
$col=0;
foreach($row_data as $value) {
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $value);
$row++;
$col++;}
}