안녕하세요 이동규(LiveDK)입니다.

 

ListView에 있는 데이터를 파일로 저장하려하는중 엑셀파일을 이용하여 쓰기를 시도하였으나 이는 대상 컴퓨터에 동일한 버전의 Excel 이 설치 되어 있지 않으면 읽고 쓰기에 어려움이 있어 CSV 를 이용하여 파일 작성을 해보았습니다.

 

파일 작성을 위해 StreamWriter 를 이용해보았습니다. 상당히 간단하기 때문에 별다른 설명 없이 코드만 첨부 하겠습니다.

 

StreamWriter sw = new StreamWriter("aa.csv", false, Encoding .Unicode);

foreach (ListViewItem lvi in listView_score.Items)

{

      sw.WriteLine(lvi.Text + "\t" + lvi.SubItems[1].Text);

}

sw.Close();

(코드.1)

 

(출력.1)

 

 

+ 추가1, 각각의 칸이동은(좌우) 탭을 넣어주면됩니다(\t)

+ 추가2, 각줄의 이동은 WriteLine 이용하였기 때문에 자동이지요 :) (\r) 하시면 됩니다.

  1. Celexa 2010/08/27 08:21 답글수정삭제

    Work out ferments the humors, casts them into their adapted channels, throws eccentric redundancies, and helps cosmos in those secret distributions, without which the body cannot subsist in its vigor, nor the incarnation role of with cheerfulness.

트랙백 주소 :: http://dklee.net/85/trackback/
옵션
댓글 달기