-1

コードから Excel レポートを作成しようとしています。基本的に 2 番目の if ステートメントに到達すると、データは最初の列とは異なる列に移動します。基本的には列 B から始まります。これは常に開始列である必要があります。私はこれをしますか?

arrData = clsData.GetReport(strStartDate, strEndDate);

dataCount = arrData.Count;
string col = "B";

foreach (string item in arrData)
{
    string[] stuff = item.Split('\t');


    if (stuff[0].Equals("Machine1"))
    {
         if (stuff[5].Equals("M")) 
         {
            row = 5;
            ws.Cells[row, col] = stuff[1];                   // Morning Shift Total 
            col = IncCol(col);
         }
    }
    else 
    {
         if (stuff[5].Equals("N")) 
         {
            row = 6;
            ws.Cells[row, col] = stuff[1];                   //Night Shift Total 
            col = IncCol(col);
         }
    }


    if (stuff[0].Equals("Machine2"))
    {
        if (stuff[5].Equals("M"))
        {
            row = 10;
             ws.Cells[row, col] = stuff[1];                   //Morning Shift Total 
            col = IncCol(col);
        }
    }
    else
    {
        if (stuff[5].Equals("N"))
        {
            row = 11;
            ws.Cells[row, col] = stuff[1];                   //Night Shift Total 
            col = IncCol(col);
        }
    }
4

1 に答える 1