C# CSV文件读取(带换行单元格中内容处理)
生活随笔
收集整理的這篇文章主要介紹了
C# CSV文件读取(带换行单元格中内容处理)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//讀取內容 StringBuilder sbContent = new StringBuilder(); using (StreamReader sr = new StreamReader(Application.StartupPath + "/content.txt")) { string line; while ((line = sr.ReadLine()) != null) { //雙引號開頭,中間處理換行 if (line.Length > 0 && line[0] == '"') { string temp = line.Substring(1); while ((line = sr.ReadLine()) != null) { if (line.Length > 0 && line[line.Length - 1] == '"') { temp += line.Substring(0, line.Length - 1); sbContent.Append(temp + "\r\n"); break; } else { temp += line; } } } else { sbContent.Append(line + "\r\n"); } } }
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎
總結
以上是生活随笔為你收集整理的C# CSV文件读取(带换行单元格中内容处理)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ubuntu 安装 samba 实现文件
- 下一篇: 李宏毅:1 天搞懂深度学习,我总结了 3