Пример #1
0
        /// <summary>
        /// 导出到响应流
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="orderStr"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="cmdParams"></param>
        /// <returns></returns>
        public static bool ExportToExcel(System.Web.HttpResponse response, string fileName, string sheetName, string sql, string orderStr, int pageIndex, int pageSize, List <string[]> renameList, params SqlParameter[] cmdParams)
        {
            DataTable dt;

            using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectingString))
            {
                dt = SqlHelper.GetPagedDataTable(conn, sql, orderStr, pageIndex, pageSize, cmdParams);
            }
            return(NPOIHelper.CreateXls(response, fileName, sheetName, dt, renameList));
        }
Пример #2
0
        /// <summary>
        /// 获取EasyUI所需的Json
        /// </summary>
        /// <returns></returns>
        public static string GetEasyUIJson(string sql, string orderStr, int pageIndex, int pageSize, params SqlParameter[] cmdParams)
        {
            string    jsonResult;
            int       rowsTotal;
            DataTable dt;

            using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectingString))
            {
                rowsTotal = SqlHelper.GetRowsCount(conn, sql, cmdParams);
                dt        = SqlHelper.GetPagedDataTable(conn, sql, orderStr, pageIndex, pageSize, cmdParams);
            }
            jsonResult = JSONHelper.DataTableToJson(dt);
            jsonResult = "{\"total\":" + "\"" + rowsTotal.ToString() + "\",\"rows\":" + jsonResult + "}";
            return(jsonResult);
        }