I have a c# console program that downloads an .xls
file that gets converted to .csv
file using
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);
In one of the columns, the text needs to be word wrapped. How can I do that? Data looks like this
"The District of Columbia
ZIP 11101.
"
The column should actually be "The District of Columbia ZIP 11101."
After you supply text you should set the cell's IsTextWrapped style to true
Remove the line breaks using something like this: