如何从Word文件中删除空行 [英] How to delete empty lines from a word file

查看:121
本文介绍了如何从Word文件中删除空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在从MS Word文件中获取数据到VB.Net中的文本框中,并逐段显示它.它工作正常,但问题在于它甚至将空白显示为段落.
是否有消除空格的方法,以便仅将Word文件中的文本显示在文本框中?

没什么急事,谁能帮我.

谢谢

Hi,

I am fetching data from a MS Word file into a text box in VB.Net and am displaying it paragraph by paragraph. It is working fine but the problem is that it is displaying even the empty spaces as paragraph.
Is there a way to eliminate the spaces so that only the text from the Word file is displayed in the text box ?

It is little urgent, can anyone please help me.

Thanks

推荐答案

基督徒的Amado回答非常好,但是在您发表评论后,我建议您阅读有关 ^ ],尤其是:子字符串 [ ^ ], [ ^ ],正确 [中端 [
The Christian''s Amado answer is very good, but after your comments, i recomend you to read about String methods[^], especially: Substring[^], Replace[^] and many others.
You can see the old MS Visual Basic methods too: Left[^], Right[^], Mid[^].

For example, to replace Chr(13) with "" (empty string), use this:
Dim sTmp as String = String.Empty
'inside the loop
sTmp = Trim(p.Range.Text)
sTmp.Replace(Chr(13),"")


对于空字符串,请使用 Trim()方法.此方法删除特定字符串中的所有空格.

http://msdn.microsoft.com/en-us/library/t97s7bs3.aspx [ ^ ]

希望它能以任何方式提供帮助.
For empty string use Trim() Method. This method removes all spaces in a particular string.

http://msdn.microsoft.com/en-us/library/t97s7bs3.aspx[^]

Hope it helps in any way.


这篇关于如何从Word文件中删除空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆