我正在从asp.net填写我的Excel工作表,但在Excel中我收到错误和错误的值
错误:
小心,我们在您的工作簿中发现了一个或多个圆形参考文献,这些参考文献可能会导致您的公式不正确地被计算在内。
CODE:
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Precise Technology Consultants";
var DataContext = new EmployeeAtdDataContext();
//var EmployeeAtd = DataContext.GetAttendance_Sp();
IEnumerable<GetAtdRecord_SpResult> EmployeeAtd = DataContext.GetAtdRecord_Sp(null).ToList();
var names = (from n in DataContext.EmployeeAtds select n).Distinct();
ViewData["EmplID"] = new SelectList(names, "EmplID", "EmplName");
return View(EmployeeAtd);
}
public ActionResult About()
{
return View();
}
public ActionResult ToExcel()
{
var DataContext = new EmployeeAtdDataContext();
var grid = new GridView();
grid.DataSource = DataContext.GetAtdRecord_Sp(null).ToList();
grid.DataBind();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=AttendanceSheet.xls");
Response.ContentType = "application/ms-excel";
Response.Charset = "";
StringWriter sw = new StringWriter();
System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);
grid.RenderControl(htw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
return RedirectToAction("Index");
}
SQL QUERY:
WITH Times AS
( SELECT emp.EmplID,
emp.EmplName,
InTime = MIN(atd.RecTime),
OutTime = MAX(atd.RecTime),
TimeWorked = DATEDIFF(MINUTE, MIN(atd.RecTime), MAX(atd.RecTime)),
OverTime = DATEDIFF(MINUTE, MIN(atd.RecTime), MAX(atd.RecTime)) - 480,
[DateVisited] = atd.RecDate
FROM AtdRecord atd
INNER JOIN HrEmployee emp
ON atd.EmplID = emp.EmplID
GROUP BY emp.EmplID, emp.EmplName, atd.RecDate
HAVING COUNT(atd.RecTime) > 1
)
SELECT t.EmplID,
t.EmplName,
t.InTime,
t.OutTime,
t.DateVisited,
TimeWorked = CONVERT(CHAR(5), DATEADD(MINUTE, t.TimeWorked, 0), 8),
OverTime = CASE WHEN t.OverTime < 0 THEN '-' ELSE '' END +
CONVERT(CHAR(5), DATEADD(MINUTE, ABS(t.OverTime), 0), 8)
FROM Times t
使用MVC 3和linq to sql
检查最后一列,加班,ti应该取消一个值,例如-07:27但事实并非如此
答案 0 :(得分:2)
Excel中的循环引用始终由公式引起。使用Excel提供的工具查找包含循环引用的单元格。然后深入查询问题单元格中的公式引用并解析所有引用,直到找到循环引用的原因。