0
我在MYSQL表看起来像这样(注意HTML代码):如何在MYSQL/PHP剥离数据输出的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 |
|------------------------------------------------------------------|
我使用PHPExcel在PHP中提取数据并将其放在一个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++;}
}
这个问题与http://stackoverflow.com/questions/13243332相同吗? – Pang
不,那个问题是如何用html去除一行。这只是关于剥离html和离开数据。 – Merica