/// <summary>
/// 点击打印按钮事件
/// </summary>
/// <param></param>
/// <param></param>
protected void Sendbu_Click(object sender, EventArgs e)
{
try
{
//查找部门分类用户
DataTable Duser = EduOA.DBUtility.DbHelperSQL.Query("select count(*) as count,d.Id as DId FROM OA_User u,OA_Department d where u.DepartmentID=d.Id group by d.Id").Tables[0];
ExcelClass Ec = new ExcelClass();//创建Excel操作类对象
int Ycount = 1;
Ec.CreateExceFile();//创建Excel文件
Ec.setValue(Ycount, 1, "CENTER", "组织部门");
Ec.setValue(Ycount, 2, "CENTER", "姓名");
Ec.setValue(Ycount, 3, "CENTER", "性别");
Ec.setValue(Ycount, 4, "CENTER", "职位");
Ec.setValue(Ycount, 5, "CENTER", "移动电话");
Ec.setValue(Ycount, 6, "CENTER", "电话");
Ec.setValue(Ycount, 7, "CENTER", "电子邮箱");
Ec.setBorder(1, 1, 1, 1, 50);
Ec.setBorder(1, 2, 2, 2, 20);
Ec.setBorder(1, 5, 5, 5, 20);
Ec.setBorder(1, 6, 6, 6, 20);
Ec.setBorder(1, 7, 7, 7, 20);
for (int i = 0; i < Duser.Rows.Count; i++)
{
Ycount += 1;
Ec.setValue(Ycount, 1, "CENTER", Common.DeleteHtml(Getdept(Duser.Rows[i]["count"], Duser.Rows[i]["DId"])));
DataTable dtuser = GetData(Duser.Rows[i]["DId"]);
for (int k = 0; k < dtuser.Rows.Count; k++)
{
Ec.setValue(Ycount, 2, "CENTER", dtuser.Rows[k]["TrueName"].ToString());
Ec.setValue(Ycount, 3, "CENTER", dtuser.Rows[k]["sex"].ToString());
Ec.setValue(Ycount, 4, "CENTER", dtuser.Rows[k]["PositionId"].ToString());
Ec.setValue(Ycount, 5, "CENTER", dtuser.Rows[k]["Telephone"].ToString());
Ec.setValue(Ycount, 6, "CENTER", dtuser.Rows[k]["Mobile"].ToString());
Ec.setValue(Ycount, 7, "CENTER", dtuser.Rows[k]["Email"].ToString());
Ycount += 1;
}
}
string path = Server.MapPath("Contactfiles\\");
Ec.SaveAs(path+"通讯录.xlsx");
//*******释放Excel资源***********
Ec.ReleaseExcel();