MSDN中的描述:使用模拟时,ASP.NET 应用程序可以用发出请求的用户的 Windows 标识(用户帐户)执行。模拟通常用于依赖 Microsoft Internet 信息服务 (IIS) 来对用户进行身份验证的应用程序。默认情况下禁用 ASP.NET 模拟。如果对某 ASP.NET 应用程序启用了模拟,该应用程序将运行在标识上下文中,其访问标记被 IIS 传递给 ASP.NET。该标记既可以是已通过身份验证的用户标记(如已登录的 Windows 用户的标记),也可以是 IIS 为匿名用户提供的标记(通常为 IUSR_MACHINENAME 标识)。 当启用模拟时,只有应用程序代码运行在被模拟的用户的上下文中。将使用 ASP.NET 进程的标识编译应用程序和加载配置信息。有关更多信息,请参见配置 ASP.NET 进程标识。编译的应用程序将放在 Temporary ASP.NET files 目录中。所模拟的应用程序标识需要对该目录的读/写访问权限。所模拟的应用程序标识还需要至少对应用程序目录和子目录中的文件的读访问权限。有关更多信息,请参见 ASP.NET 必需的访问控制列表 (ACL)。
http://www.cshap.cn/ 或许能找到你感兴趣的问题
给你一段导出到excel表格的代码! private void OutputExcel() { Excel.Application excel; int rowIndex=2; int colIndex=0; excel= new Excel.ApplicationClass();; Excel.Workbook xBk = excel.Workbooks.Add(1); Excel.Worksheet xSt = (Excel.Worksheet)xBk.Worksheets[1]; excel.Visible=true;
// //取得标题 // this.dv=new DataView(ds.Tables[0]); foreach(DataColumn col in dv.Table.Columns) { colIndex++; excel.Cells[2,colIndex] = col.ColumnName; xSt.get_Range(excel.Cells[2,colIndex],excel.Cells[2,colIndex]).HorizontalAlignment = Excel.XlVAlign.xlVAlignCenter;//设置标题格式为居中对齐 }
或许能找到你感兴趣的问题
private void OutputExcel()
{
Excel.Application excel;
int rowIndex=2;
int colIndex=0;
excel= new Excel.ApplicationClass();;
Excel.Workbook xBk = excel.Workbooks.Add(1);
Excel.Worksheet xSt = (Excel.Worksheet)xBk.Worksheets[1];
excel.Visible=true;
//
//取得标题
//
this.dv=new DataView(ds.Tables[0]);
foreach(DataColumn col in dv.Table.Columns)
{
colIndex++;
excel.Cells[2,colIndex] = col.ColumnName;
xSt.get_Range(excel.Cells[2,colIndex],excel.Cells[2,colIndex]).HorizontalAlignment = Excel.XlVAlign.xlVAlignCenter;//设置标题格式为居中对齐
}
//
//取得表格中的数据
//
foreach(DataRowView row in dv)
{
rowIndex ++;
colIndex = 0;
foreach(DataColumn col in dv.Table.Columns)
{
colIndex ++;
if(col.DataType == System.Type.GetType("System.DateTime"))
{
excel.Cells[rowIndex,colIndex] = (Convert.ToDateTime(row[col.ColumnName].ToString())).ToString("yyyy-MM-dd");
xSt.get_Range(excel.Cells[rowIndex,colIndex],excel.Cells[rowIndex,colIndex]).HorizontalAlignment = Excel.XlVAlign.xlVAlignCenter;//设置日期型的字段格式为居中对齐
}
else
if(col.DataType == System.Type.GetType("System.String"))
{
excel.Cells[rowIndex,colIndex] = "'"+row[col.ColumnName].ToString();
xSt.get_Range(excel.Cells[rowIndex,colIndex],excel.Cells[rowIndex,colIndex]).HorizontalAlignment = Excel.XlVAlign.xlVAlignCenter;//设置字符型的字段格式为居中对齐
}
else
{
excel.Cells[rowIndex,colIndex] = row[col.ColumnName].ToString();
}
}
}
//
//加载一个合计行
//
int rowSum = rowIndex+1;
excel.Cells[rowSum,2] = this.lal_Num.Text;
xSt.get_Range(excel.Cells[rowSum,1],excel.Cells[rowSum,1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
//
//设置选中的部分的颜色
//
xSt.get_Range(excel.Cells[1,1],excel.Cells[1,9]).Select();
xSt.get_Range(excel.Cells[2,1],excel.Cells[2,colIndex]).Interior.ColorIndex = 19;//设置为浅黄色,共计有56种
//
//取得整个报表的标题
//
excel.Cells[1,1] =Str.ToString();
//
//设置整个报表的标题格式
//
xSt.get_Range(excel.Cells[1,1],excel.Cells[1,1]).Font.Bold = true;
xSt.get_Range(excel.Cells[1,1],excel.Cells[1,1]).Font.Size = 18;
//
//设置报表表格为最适应宽度
//
xSt.get_Range(excel.Cells[2,1],excel.Cells[2,colIndex]).Select();
xSt.get_Range(excel.Cells[2,1],excel.Cells[2,colIndex]).Columns.AutoFit();
//
//设置整个报表的标题为跨列居中
//
xSt.get_Range(excel.Cells[1,1],excel.Cells[1,colIndex]).Select();
xSt.get_Range(excel.Cells[1,1],excel.Cells[1,colIndex]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenterAcrossSelection;
//
//绘制边框
//
xSt.get_Range(excel.Cells[2,1],excel.Cells[rowSum,colIndex]).Borders.LineStyle = 1;
xSt.get_Range(excel.Cells[2,1],excel.Cells[rowSum,1]).Borders[Excel.XlBordersIndex.xlEdgeLeft].Weight = Excel.XlBorderWeight.xlThick;//设置左边线加粗
xSt.get_Range(excel.Cells[2,1],excel.Cells[4,colIndex]).Borders[Excel.XlBordersIndex.xlEdgeTop].Weight = Excel.XlBorderWeight.xlThick;//设置上边线加粗
xSt.get_Range(excel.Cells[2,colIndex],excel.Cells[rowSum,colIndex]).Borders[Excel.XlBordersIndex.xlEdgeRight].Weight = Excel.XlBorderWeight.xlThick;//设置右边线加粗
xSt.get_Range(excel.Cells[rowSum,1],excel.Cells[rowSum,colIndex]).Borders[Excel.XlBordersIndex.xlEdgeBottom].Weight = Excel.XlBorderWeight.xlThick;//设置下边线加粗
//
//显示效果
//
}
using Excel;