Mehmet Fatih

Mehmet Fatih

  • 858
  • 939
  • 41.2k

Problem with extracting empty data in word automation

Feb 14 2024 11:55 AM

I transfer the data to a word document with word automation. However, if the data is empty, I get output as shown in the picture. How do we ensure that a blank line appears if there is no data?

I have tried this but it didn't work.

if (dr["gorusme2"].ToString() == String.Empty)
{
    myMergeField.Select();
    oWord.Selection.TypeText("");
}
else
{
    if (fieldName == "gorusme2")
    {
        myMergeField.Select();
        oWord.Selection.TypeText(dr["gorusme2"].ToString());
    }
}

 


Answers (4)