110,533
社区成员
发帖
与我相关
我的任务
分享
for (j = 0; j < answTDs.Tables[0].Rows.Count; j++)
{
excel.Cells[x + 3 + 2 * j, 2] = answTDs.Tables[0].Rows[j][0];
excel.Cells[x + 3 + 2 * j, 3] = "计数";
excel.Cells[x + 4 + 2 * j, 3] = "比例";
string dad = DateTime.Now.Date.ToShortDateString();
sqlStr = "select COUNT(*) from 提交答案表 where 项目编号='" + myDs.Tables[0].Rows[i][0] + "' and 题号=" + quesDs.Tables[0].Rows[m][1] + " and 选择信息 like '%(17(" + (j + 1) + "))%'";
sqlStr = sqlStr + " and [拨号标记]='完成'and 完成时间 between '" + DateTime.Now.Date.ToShortDateString() + " 00:00:00' and '" + DateTime.Now.Date.ToShortDateString() + " 23:59:59'";
SqlDataAdapter jsDa = new SqlDataAdapter(sqlStr, myConn);
DataSet jsDs = new DataSet();
jsDa.Fill(jsDs);
int total = Convert.ToInt32(jsDs.Tables[0].Rows[0][0]);
int z = 0;
for (z = 0; z < answDs.Tables[0].Rows.Count; z++)
{
sqlStr = "select COUNT(*) from 提交答案表 where 项目编号='" + myDs.Tables[0].Rows[i][0] + "' and 题号=" + quesDs.Tables[0].Rows[m][1] + " and 选择信息 like '%(17(" + (j + 1) + "))%'";
sqlStr = sqlStr + "and 选择项='" + (z + 1) + "' and [拨号标记]='完成'and 完成时间 between '" + DateTime.Now.Date.ToShortDateString() + " 00:00:00' and '" + DateTime.Now.Date.ToShortDateString() + " 23:59:59'";
jsDa = new SqlDataAdapter(sqlStr, myConn);
jsDs = new DataSet();
jsDa.Fill(jsDs);
excel.Cells[x + 3 + 2 * j, 4 + z] = jsDs.Tables[0].Rows[0][0];
double percent = Convert.ToDouble(jsDs.Tables[0].Rows[0][0]) * 100 / Convert.ToDouble(total);
excel.Cells[x + 4 + 2 * j, 4 + z] = percent.ToString("0.0") + "%";
}
excel.Cells[x + 3 + 2 * j, 4 + z] = total;
excel.Cells[x + 4 + 2 * j, 4 + z] = "100.0%";
}
object[,] objData = new Object[maxRowCountData, maxColumnCountData];
for (int i = 1; i < data.Length - 1; i++)
//给objData 赋值
Excel.Range CurRange = GetRange(x1, y1, x2, y2);//选择要写入的区域
CurRange.Value2 = objData;