EDN Admin
Well-known member
<font face="Verdana, Geneva, Arial, Sans-serif" size=2>Hello All,</font>
<font face=Verdana size=2><font face="Trebuchet MS We are supposed to create a Word doc file for our client that is to be used for printing a large list of names and addresses. </font>I am facing the below problem in my C#.net Application.</font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2>Eg.</font>
<span style="font-size:10pt;font-family:Courier New I am reading the values from the Access Database and showing it in the MS Word Document using C#.net windows Application.
<font size=2><font face="Verdana, Geneva, Arial, Sans-serif The original name looks like: "<span style="font-size:10pt;font-family:Courier New Michelle Accuso-Stevens"</font></font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New From DataBase side the name looks like this.</font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New <span style="font-size:10pt;font-family:Courier New Mich<font style="background-color:#ffcc00 </font>el<font style="background-color:#ffcc00 </font>le<font style="background-color:#c0c0c0 </font>Acc<font style="background-color:#ffcc00 </font>uso-Ste<font style="background-color:#ffcc00 </font>ve<font style="background-color:#ff9900 </font>ns [some spaces inside the string] </font> <font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New <span style="font-size:10pt;font-family:Courier New <font size=2>
</font><font color="#0000ff" size=2>foreach</font><font size=2> (</font><font color="#008080" size=2>DataRow</font><font size=2> myRow </font><font color="#0000ff" size=2>in</font><font size=2> dsContacts.Tables[0].Rows)
{
</font><font color="#0000ff" size=2>if</font><font size=2> (</font><font color="#800000" size=2>""</font><font size=2> != myRow[</font><font color="#800000" size=2>"FirstName"</font><font size=2>].ToString() || </font><font color="#800000" size=2>""</font><font size=2> != myRow[</font><font color="#800000" size=2>"LastName"</font><font size=2>].ToString().Trim())
{
</font><font color="#0000ff" size=2>if</font><font size=2> (</font><font color="#800000" size=2>""</font><font size=2> != myRow[</font><font color="#800000" size=2>"Title"</font><font size=2>].ToString())
{
sw.Write(myRow[</font><font color="#800000" size=2>"Title"</font><font size=2>].ToString() + </font><font color="#800000" size=2>" "</font><font size=2>);
}
</font><font color="#0000ff" size=2>if</font><font size=2> (</font><font color="#800000" size=2>""</font><font size=2> != myRow[</font><font color="#800000" size=2>"FirstName"</font><font size=2>].ToString().Trim())
{
sw.Write(myRow[</font><font color="#800000" size=2>"FirstName"</font><font size=2>].ToString().Trim() + </font><font color="#800000" size=2>" "</font><font size=2>);
}
</font><font color="#0000ff" size=2>if</font><font size=2> (</font><font color="#800000" size=2>""</font><font size=2> != myRow[</font><font color="#800000" size=2>"LastName"</font><font size=2>].ToString())
{
sw.Write(myRow[</font><font color="#800000" size=2>"LastName"</font><font size=2>].ToString());
}
sw.WriteLine();
} </font></font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New <span style="font-size:10pt;font-family:Courier New </font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New <span style="font-size:10pt;font-family:Courier New How Can I replace the spaces inside the string?</font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New <span style="font-size:10pt;font-family:Courier New Could you please share your ideas on my query as soon as possible?</font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2>Thanks and Regards</font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2>Madhu.P</font>
View the full article
<font face=Verdana size=2><font face="Trebuchet MS We are supposed to create a Word doc file for our client that is to be used for printing a large list of names and addresses. </font>I am facing the below problem in my C#.net Application.</font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2>Eg.</font>
<span style="font-size:10pt;font-family:Courier New I am reading the values from the Access Database and showing it in the MS Word Document using C#.net windows Application.
<font size=2><font face="Verdana, Geneva, Arial, Sans-serif The original name looks like: "<span style="font-size:10pt;font-family:Courier New Michelle Accuso-Stevens"</font></font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New From DataBase side the name looks like this.</font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New <span style="font-size:10pt;font-family:Courier New Mich<font style="background-color:#ffcc00 </font>el<font style="background-color:#ffcc00 </font>le<font style="background-color:#c0c0c0 </font>Acc<font style="background-color:#ffcc00 </font>uso-Ste<font style="background-color:#ffcc00 </font>ve<font style="background-color:#ff9900 </font>ns [some spaces inside the string] </font> <font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New <span style="font-size:10pt;font-family:Courier New <font size=2>
</font><font color="#0000ff" size=2>foreach</font><font size=2> (</font><font color="#008080" size=2>DataRow</font><font size=2> myRow </font><font color="#0000ff" size=2>in</font><font size=2> dsContacts.Tables[0].Rows)
{
</font><font color="#0000ff" size=2>if</font><font size=2> (</font><font color="#800000" size=2>""</font><font size=2> != myRow[</font><font color="#800000" size=2>"FirstName"</font><font size=2>].ToString() || </font><font color="#800000" size=2>""</font><font size=2> != myRow[</font><font color="#800000" size=2>"LastName"</font><font size=2>].ToString().Trim())
{
</font><font color="#0000ff" size=2>if</font><font size=2> (</font><font color="#800000" size=2>""</font><font size=2> != myRow[</font><font color="#800000" size=2>"Title"</font><font size=2>].ToString())
{
sw.Write(myRow[</font><font color="#800000" size=2>"Title"</font><font size=2>].ToString() + </font><font color="#800000" size=2>" "</font><font size=2>);
}
</font><font color="#0000ff" size=2>if</font><font size=2> (</font><font color="#800000" size=2>""</font><font size=2> != myRow[</font><font color="#800000" size=2>"FirstName"</font><font size=2>].ToString().Trim())
{
sw.Write(myRow[</font><font color="#800000" size=2>"FirstName"</font><font size=2>].ToString().Trim() + </font><font color="#800000" size=2>" "</font><font size=2>);
}
</font><font color="#0000ff" size=2>if</font><font size=2> (</font><font color="#800000" size=2>""</font><font size=2> != myRow[</font><font color="#800000" size=2>"LastName"</font><font size=2>].ToString())
{
sw.Write(myRow[</font><font color="#800000" size=2>"LastName"</font><font size=2>].ToString());
}
sw.WriteLine();
} </font></font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New <span style="font-size:10pt;font-family:Courier New </font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New <span style="font-size:10pt;font-family:Courier New How Can I replace the spaces inside the string?</font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2><span style="font-size:10pt;font-family:Courier New <span style="font-size:10pt;font-family:Courier New Could you please share your ideas on my query as soon as possible?</font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2>Thanks and Regards</font>
<font face="Verdana, Geneva, Arial, Sans-serif" size=2>Madhu.P</font>
View the full article