c#txt를 excel로 변환
3507 단어 tools
앞말
때때로 우리는 txt 형식의 표 데이터를 얻을 수 있다. 사전에서 내보낸 단어본일 수도 있고, 설정된 데이터 내보내기를 기획할 수도 있다. 데이터를 쉽게 읽고 찾을 수 있도록 excel로 전환해야 한다.본고는 c#로 표 형식의 txt 파일을 excel 파일로 내보냅니다.
본문
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
HSSFWorkbook hssfworkbook = new HSSFWorkbook();
ISheet sheet = hssfworkbook.CreateSheet(txtName);
IRow dataRow = sheet.CreateRow(i);
ICell cell = dataRow.CreateCell(j);
cell.SetCellValue(line[j]);
string[] txtLines = File.ReadAllLines(Environment.CurrentDirectory + txtPath + "//" + txtName);
for (int i = 0; i < txtLines.Length; ++i)
{
string[] line = txtLines[i].Split('\t');
}
DirectoryInfo folder = new DirectoryInfo(Environment.CurrentDirectory + txtPath);
foreach (FileInfo file in folder.GetFiles("*.txt"))
{
ConvertTxt2Excel.Convert(xlsxPath, txtPath, file.Name);
}
Environment.CurrentDirectory + xlsxPath + "//" + xlsName
FileStream file = new FileStream(Environment.CurrentDirectory + xlsxPath + "//" + xlsName, FileMode.Create);
hssfworkbook.Write(file);
file.Close();
만약 잘못이 있으면 지적을 환영합니다.
email:dxmdxm1992#gmail.com
blog: http://blog.csdn.net/david_dai_1108
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다시는 아무것도 수동으로 설치하지 마십시오.웹 앱을 만들어 봅시다. 그런 다음 someproject.config.js 를 생성하거나 .someproject 입니다. 또한 앱의 기존 파일, 아마도 app.js 등을 업데이트합니다. 마지막으로 npm run st...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.