c# 操作Excel 如何设置换行
发布网友
发布时间:2023-09-15 23:27
我来回答
共3个回答
热心网友
时间:2024-11-26 07:31
SaveFileDialog kk = new SaveFileDialog();
kk.Title = "保存EXECL文件";
kk.Filter = "excel(*.xls) |*.xls |所有文件(*.*) |*.*";
kk.FilterIndex = 1;
if (kk.ShowDialog() == DialogResult.OK)
{
string FileName = kk.FileName;
if (File.Exists(FileName))
File.Delete(FileName);
FileStream objFileStream;
StreamWriter objStreamWriter;
objFileStream = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Write);
objStreamWriter = new StreamWriter(objFileStream, System.Text.Encoding.Unicode);
objStreamWriter.WriteLine("<table><tr><td>" + "aa" + "<br style='mso-data-placement:same-cell;'/> " + "cc" + "<br style='mso-data-placement:same-cell;'/> " + "dd" + "</td><td>"+"pp"+"</td></tr></table>");
//objStreamWriter.WriteLine("aaaa" + Convert.ToChar(10) + "bbb");
objStreamWriter.Close();
objFileStream.Close();
MessageBox.Show(this, "保存EXCEL成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
热心网友
时间:2024-11-26 07:32
\\n 第一个\为转义字符
热心网友
时间:2024-11-26 07:32
objSheet.Cells[temp + 2, 2] = Convert.ToChar(10) + proctName;
Convert.ToChar(10) Excel单元格内换行