关于导出--分页

博客还是要写起来,方便以后查看。

最近做了文件的导出功能。 

 1  String tempPath = System.Web.HttpContext.Current.Server.MapPath("~/file/buKaoShiDeRen.xlsx");   //先获取路径,
 2             if (File.Exists(tempPath))
 3             {
 4                 // 2、根据路径字符串判断是文件还是文件夹
 5                 FileAttributes attr = File.GetAttributes(tempPath);
 6                 // 3、根据具体类型进行删除
 7                 if (attr == FileAttributes.Directory)
 8                 {
 9                     // 3.1、删除文件夹
10                     Directory.Delete(tempPath, true);
11                 }
12                 else
13                 {
14                     // 3.2、删除文件
15                     File.Delete(tempPath);
16                 }
17               //  File.Delete(tempPath);  
18             }

将DataTable 转换为表格文件。

 DataTableToExcel.DataTableToExcel.ExportToExcel(tempPath, "未考试人员名单", dt);
//这是一个控件  直接添加引用,用主这还是很方便的。 

分页查询 

1 select T.*
2 from( 
3 select  row_number() over(ORDER BY ID  DESC) as row ,* from T_biaoming
4 ) as  T
5 where row between 1 and 50
6  --where row between 0 and 10, 1 * PageSize + 1, PageIndex * PageSize

 

posted @ 2020-12-01 16:19  YaShi  阅读(90)  评论(0编辑  收藏  举报