首页 \ 问答 \ 如何使用PHPExcel从合并单元格中获取值?(How to get a value from merged cell using PHPExcel?)

如何使用PHPExcel从合并单元格中获取值?(How to get a value from merged cell using PHPExcel?)

在这里,我正在阅读一份excel表,可能有也可能没有合并的单元格。 好好循环当前工作表中的单元格,如果我遇到合并单元格,那么我应该能够找到它的范围和值。

这些是步骤: -

1.读取单元格A1或B1或B7或A9。
2.检查它是否与任何其他单元格合并。
3.如果合并单元格,则获取合并范围,例如:A1到A7或A1到D1
最后在获得范围后获得价值。


Here, I'm reading an excel sheet which may or may not have merged cells. Well looping through the cells in the current sheet, if i come across a merged cell then i should be able to find its range and value.

These are the steps:-

1. Reading the cell A1 or B1 or B7 or A9.
2. Check whether its merged with any other cell.
3. If the cells are merged then get the range of the merge, for ex: A1 to A7 or A1 to D1
4. And finally after getting the range get the value.


原文:https://stackoverflow.com/questions/46315768
更新时间:2023-11-16 22:11

最满意答案

是的,您可以将整篇文章提交到数据库。 但是,在你提交之前; 尝试使用此功能:

function dataready($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
} 

例:

 dataready($_POST['editor']);

所以你可以使用任何你想要的PDO或Mysqli。

要在打印文章时避免回显HTML元素,请使用以下函数:

  html_entity_decode($article_text);

希望这对你有用。

PS。 使用列类型TEXT为您的数据库是好的。 如果要向该列添加更多文本,也可以使用LONGTEXT。


Yes, You can submit your entire article to the database. But, before you submit it; try to use this function:

function dataready($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
} 

Example:

 dataready($_POST['editor']);

So you can use whatever you want PDO or Mysqli.

To avoid echoing the HTML elements when you print the article, use this function:

  html_entity_decode($article_text);

Hope this works for you.

PS. using column type TEXT for your database is fine. You can also use LONGTEXT if you want to add more text to that column.

相关问答

更多
  • 尝试这个 var val= CKEDITOR.instances['youreditorid'].getData(); 这可能对你有帮助。 Try this var val= CKEDITOR.instances['youreditorid'].getData(); this may help you.
  • 这可能不是100%的目标,但它是我使用的,它运作良好。 TinyMCE使用HTML textarea标记和一些JavaScript来允许客户端格式化信息。 然后普通的“提交”将textarea的内容发送到服务器,您可以在POST方法请求中接收它,并将其存储在数据库中。 TinyMCE的样本JS: