1

how to recognize new line c# while uploading word documents..? i have to give next line as a new word in word document here what is happening means if i add three or more words in .doc in separate line its taking as one word i want to separate the words but if i give a space after a word it is taking as expected without giving space if i start a new word in new line its taking as one word

money power cash

moneypowercash

like this iam getting here if i give space after these words its getting as expected how to resolve this issue here i will give my code to generating this keyword

protected void btnSubmit_Click(object sender, EventArgs e)
{
 try
 {

   if (cmbDepartment.SelectedValue != "0" && cmbDocumentType.SelectedValue != "0")
     {

      TodayDate = DateTime.Today.ToString("yyyy-MM-dd");
      TempFolder = System.Configuration.ConfigurationManager.AppSettings["TempWorkFolder"];
      TextReader reader = new FilterReader(TempFolder + Session["EncyptImgName"]);
      StringBuilder Keywords = new StringBuilder();
      using (reader)
      {
         Keywords = Keywords.Append(reader.ReadToEnd());
      }
      //remove common words
      string[] removablewords = { ":", ".", "~"};
      foreach (string st in removablewords)
      {
           Keywords.Replace(st, " ");
      }    

      //Reomve unwated spaces
      while (Keywords.ToString().Contains("  "))
      {
          Keywords.Replace("  ", " ");
      }
      string str = Keywords.ToString();
      Keywords.Clear();
      Keywords.Append("<words><s>" + str.Replace(" ", "</s><s>") + "</s></words>");
      string xml = Keywords.ToString();
      XElement items = XElement.Parse(xml);
      var groups = from t in items.Descendants("s")
                   group t by t.Value.ToLower() into g
                   select new KeyFrequency(g.Key, g.Count());
      groups = groups.OrderByDescending(g => g.Frequency).Take(15);

      keyvalues = new List<string>();
      foreach (KeyFrequency g in groups)
      {
          keyvalues.Add(g.Key);
      }

      for (key = 0; key < keyvalues.Count && key < 10; key++)
       {
       Button btn = (Button)pnlKeywords.FindControl("Button" + Convert.ToString(key + 1));
                    btn.Visible = true;
                    btn.Text = keyvalues[key];
                    btn.CommandArgument = keyvalues[key];
                }
                if (key < 10)
                {
                    for (key = key; key < 10; key++)
                    {
                        Button btn = (Button)pnlKeywords.FindControl("Button" + Convert.ToString(key + 1));
                        btn.Visible = false;
                    }
                }
                else
                {
                    AsyncFileUpload1.BackColor = System.Drawing.Color.Red;
                }
            }
        }
        catch (Exception ex)
        {
            Button1.Text = "Keywords Not Available for This Document";
            Button1.CommandArgument = null;
            Button2.Visible = false;
            Button3.Visible = false;
            Button4.Visible = false;
            Button5.Visible = false;
            Button6.Visible = false;
            Button7.Visible = false;
            Button8.Visible = false;
            Button9.Visible = false;
            Button10.Visible = false;

        }

    }
4

1 回答 1

0

For each new line, try replacing \n with "</w:t><w:br/><w:t>". It worked for me.

string.Replace("\n", "</w:t><w:br/><w:t>") 
于 2017-09-19T22:11:38.193 回答