C#从Excel中以编程方式包装文本

我有交stream#控制台程序,下载一个.xls文件,使用.csv文件转换

 string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + sourceFile + ";" + "Extended Properties=\"Excel 8.0;HDR=Yes;\""; OleDbConnection conn = null; StreamWriter wrtr = null; OleDbCommand cmd = null; OleDbDataAdapter da = null; try { conn = new OleDbConnection(strConn); conn.Open(); cmd = new OleDbCommand("SELECT * FROM [" + worksheetName + "$]", conn); cmd.CommandType = CommandType.Text; wrtr = new StreamWriter(targetFile); da = new OleDbDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); 

在其中一列中,文字需要被文字包装。 我怎样才能做到这一点? 数据看起来像这样

"The District of Columbia
ZIP 11101.
"

该栏实际上应该是"The District of Columbia ZIP 11101."

提供文本后,您应该将单元格的IsTextWrapped样式设置为true

 worksheet.Cells[0, 0].Style.IsTextWrapped = true; 

使用这样的东西删除换行符:

 string noWraps = source.Replace(Environment.NewLine, "");