本文整理汇总了C#中Common.ReadExcelContents方法的典型用法代码示例。如果您正苦于以下问题:C# Common.ReadExcelContents方法的具体用法?C# Common.ReadExcelContents怎么用?C# Common.ReadExcelContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common
的用法示例。
在下文中一共展示了Common.ReadExcelContents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnReadExcel_Click
protected void btnReadExcel_Click(object sender, EventArgs e)
{
try
{
Visible(false);
Common cm = new Common();
InitBUS();
table = new DataTable();
long countEmail = 0;
string excelContent = "application/vnd.ms-excel";
string excelContent2010 = "application/openxmlformats-officedocument-spreadsheetml.sheet";
if (fileExcel.HasFile)
{
if (fileExcel.PostedFile.ContentType != excelContent && fileExcel.PostedFile.ContentType != excelContent2010)
{
Visible(false);
pnError.Visible = true;
lblError.Text = "Vui lòng chọn file Excel";
}
else
{
if (getUserLogin().DepartmentId == 2)
{
table = ctBUS.GetClientId(getUserLogin().UserId);
}
else
{
table = ctBUS.GetClientIdSub(getUserLogin().UserId);
}
if (table.Rows.Count > 0)
{
int clienID = int.Parse(table.Rows[0]["clientId"].ToString());
DataTable dtCountEmail = ctBUS.GetCountEmail(clienID);
if (dtCountEmail.Rows[0]["isUnLimit"] + "" != "" && Convert.ToBoolean(dtCountEmail.Rows[0]["isUnLimit"])) countEmail = 1000000000000000000;
else countEmail = int.Parse(dtCountEmail.Rows[0]["under"].ToString());
}
fileName = "~/database/" + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + fileExcel.FileName;
string path = string.Concat(Server.MapPath(fileName));
fileExcel.SaveAs(path);
table = cm.ReadExcelContents(path);
if (table.Rows.Count < countEmail)
{
// string message = checkCreateCustomer(table.Rows.Count);
// if (message == "")
// {
this.dtlCustomer.DataSource = table;
this.dtlCustomer.DataBind();
LoadMailGroupLists();
// }
// else
// {
// Visible(false);
// pnError.Visible = true;
// lblError.Text = message;
// }
}
else
{
Visible(false);
pnError.Visible = true;
lblError.Text = "Vượt quá hạng ngạch tạo khách hàng!";
}
}
}
else
{
Visible(false);
pnError.Visible = true;
lblError.Text = "Vui lòng chọn file";
}
}
catch (Exception ex)
{
Visible(false);
pnError.Visible = true;
lblError.Text = "Vui lòng kiểm tra lại định dạng file, hoặc file của bạn đang được sử dụng <br/>" + ex.ToString();
logs.Error(userLogin.Username + "-Client - btnReadExcel_Click", ex);
}
}