我正在尝试从我的代码创建一个 excel 报告,基本上当我到达第二个 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);
}
}