在 VBA 中将 html 转换为纯文本 [英] Convert html to plain text in VBA
本文介绍了在 VBA 中将 html 转换为纯文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 Excel 工作表,其中包含包含 html 的单元格.如何将它们批量转换为纯文本?目前有这么多无用的标签和样式.我想从头开始写,但如果我能把纯文本写出来会容易得多.
I have an Excel sheet with cells containing html. How can I batch convert them to plaintext? At the moment there are so many useless tags and styles. I want to write it from scratch but it will be far easier if I can get the plain text out.
我可以编写一个脚本来将 html 转换为 PHP 中的纯文本,所以如果您想不出 VBA 中的解决方案,那么也许您可以建议我如何将单元格数据传递到网站并检索数据.
I can write a script to convert html to plain text in PHP so if you can't think of a solution in VBA then maybe you can sugest how I might pass the cells data to a website and retrieve the data back.
推荐答案
设置对Microsoft HTML 对象库"的引用.
Set a reference to "Microsoft HTML object library".
Function HtmlToText(sHTML) As String
Dim oDoc As HTMLDocument
Set oDoc = New HTMLDocument
oDoc.body.innerHTML = sHTML
HtmlToText = oDoc.body.innerText
End Function
蒂姆
这篇关于在 VBA 中将 html 转换为纯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文