2014-11-05 3 views
1

내가 다음 코드를에서 변환 한 후 csv 파일의 숫자에서 여분의 쉼표를 제거하는 방법 :엑셀 CSV 파일로 파일을 변환하는 엑셀

... 
"Some strings","309,145","4,964,398",,"1,194,780",, 
... 
:

Microsoft.Office.Interop.Excel.Application reportExcel = new Microsoft.Office.Interop.Excel.Application(); 
Microsoft.Office.Interop.Excel.Workbooks reportBooks = null; 
Microsoft.Office.Interop.Excel.Workbook reportBook = null; 
Microsoft.Office.Interop.Excel.Sheets reportSheets = null; 
Microsoft.Office.Interop.Excel._Worksheet reportSheet = null; 
try 
{ 
    reportBooks = reportExcel.Workbooks; 
    reportBook = reportBooks.Open(excelFilePath); 
    reportSheets = reportBook.Sheets; 
    reportSheet = reportSheets.get_Item(1); 
    if (File.Exists(csvtempFile)) 
    { 
     File.Delete(csvtempFile); 
    } 
    reportBook.SaveAs(csvtempFile, Microsoft.Office.Interop.Excel.XlFileFormat.xlCSVWindows, Type.Missing, Type.Missing, false, false); 
    ... 
} 
catch (Exception ex) 
{ 
    ... 
} 
finally 
{ 
    ... 
} 

내가 CSV 파일에 다음 텍스트를 얻을

숫자에 나와 있듯이 숫자에는 쉼표가 추가로 포함되어 있습니다.

"Some strings","309,145","4964,398",,"1194,780",, 
+0

대신', "309145", "4964398",, "1194780",,'을 원하십니까? –

+2

* 어떤 쉼표가 *? 수천을 나타내는 것 또는 빈 열을 나타내는 것? –

+0

나는 다음과 같이 썼다 : "숫자가 여분의 쉼표를 포함하는 것을 볼 때", 이렇게 : 수천을 나타내는 숫자. – tlecka

답변

0

체크 아웃이 게시물 : 다음 값 얻기를 위해 여분의 쉼표를 제거하는 방법을 알려주세요 Set data type like number, text and date in excel column using Microsoft.Office.Interop.Excel in c#

을 당신은 열 유형을 확인할 수를 변경하려는 각각의 범위를 설정 한 후 설정 숫자 형식으로 내보내기.

나는 귀엽다는 것을 알고 있지만, 더 예쁜 것을 찾지 못하면 작동 할 수도 있습니다.