VBA → C#に書き換えています。
【VBA】
lang
1'-------------------------------------------------------------------------- 2' OPEN CSV file 3'-------------------------------------------------------------------------- 4intFree = FreeFile '空番号を取得 5Open strSETB For Input As #intFree 'CSVファィルをオープン 6 7i = 0 8Do Until EOF(intFree) 9 10 Line Input #intFree, strRec '1行読み込み 11 12 i = i + 1 13 strSplit = Split(strRec, ",") 'カンマ区切りで配列へ 14 15 For j = 0 To UBound(strSplit) 16 Cells(i, j + 1) = strSplit(j) 17 Next 18 '配列をそのまま入れる方法も、ただし全て文字列として入力される 19' Range(Cells(i, 1), Cells(i, UBound(strSplit) + 1)) = strSplit 20Loop
【C#】
lang
1 //'-------------------------------------------------------------------------- 2 //' OPEN CSV file 3 //'-------------------------------------------------------------------------- 4 var strRec = new StreamReader(strSetb, Encoding.GetEncoding("UTF-8")); 5 6 var i = 0; 7 while (!strRec.EndOfStream) 8 { 9 i = i + 1; 10 var readLine = strRec.ReadLine(); 11 if (readLine == null) continue; 12 var strSplit = readLine.Split(','); 13 for (var j = 0; j < strSplit.Length; j++) 14 { 15 scr4CsvSheet.Cells[i, j + 1] = strSplit[j]; 16 } 17 }
VBAをC#に書き換えたら、処理が物凄く遅くなりました。
遅くなった原因も知りたいですが、
処理が速くなる書き方が知りたいです。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。