Excel注释在阅读过程中被截断 [英] Excel Comment truncated during reading

查看:98
本文介绍了Excel注释在阅读过程中被截断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Excel单元格中有很长的评论.

I have a very long comment in an Excel cell.

我需要能够阅读此评论.

I need to able to read this comment.

Microsoft.Office.Interop.Excel.Comment comment = ws.get_Range(ws.Cells[1, Constants.HIDDEN_DATA_COL], ws.Cells[1, Constants.HIDDEN_DATA_COL]).Comment;
if(comment!=null)
{
  Microsoft.Office.Interop.Excel.Characters chars = comment.Shape.TextFrame.Characters(System.Type.Missing, System.Type.Missing);
  string theText = chars.Text;
  MessageBox.Show(theText); //**truncated!**
}       

我读到加载字符需要循环,但是如果我不知道字符的长度,该怎么办呢?

I read that getting loading the characters need to be looped but how should I wonder how should I do it if I don't know the length of the character?

推荐答案

经过反复试验,通过实施以下方法解决了该问题:

After trial and error, solved by implementing this :

bool read = true;
                    string finalText="";
                    int j = 1;
                    int lengthMax = 200;


                    while(read)
                    {
                        string textnya = comment.Shape.TextFrame.Characters(j, lengthMax).Text;
                        finalText = finalText+textnya;
                        if (textnya.Length < lengthMax)
                        {
                            read = false;
                        }
                        else
                        {
                            j = j + lengthMax;
                        }

                    }

                    MessageBox.show(finalText); 

这篇关于Excel注释在阅读过程中被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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