Exemplo n.º 1
0
        /// <summary>
        /// 正常导出
        /// </summary>
        /// <param name="path"></param>
        /// <param name="para"></param>
        /// <param name="updatesheet">数据表类对象</param>
        /// <returns></returns>
        public string ExportExcel(string path, QueryParameters para, IGenerateSheet updatesheet)
        {
            string[] num      = path.Split('\\');
            string   filename = num[num.Length - 1];
            string   savepath = string.Empty;

            try
            {
                if (System.IO.File.Exists(path))
                {
                    using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
                    {
                        IWorkbook readworkbook = new XSSFWorkbook(stream);
                        stream.Close();
                        readworkbook = updatesheet.GenerateSheet(readworkbook, para);
                        savepath     = SaveFile(readworkbook, filename, para);
                    }
                }
                else
                {
                    SystemLog.GetInstance().Info("导出错误:模板信息不存在!");
                }
            }
            catch (Exception e)
            {
                SystemLog.GetInstance().Error(e);
            }
            return(savepath);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 正常导出
 /// </summary>
 /// <param name="path"></param>
 /// <param name="para"></param>
 /// <param name="updatesheet">数据表类对象</param>
 /// <returns></returns>
 public string ExportExcel(string path, QueryParameters para, IGenerateSheet updatesheet)
 {
     string[] num = path.Split('\\');
     string filename = num[num.Length - 1];
     string savepath = string.Empty;
     try
     {
         if (System.IO.File.Exists(path))
         {
             using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
             {
                 IWorkbook readworkbook = new XSSFWorkbook(stream);
                 stream.Close();
                 readworkbook = updatesheet.GenerateSheet(readworkbook, para);
                 savepath = SaveFile(readworkbook, filename, para);
             }
         }
         else
         {
             SystemLog.GetInstance().Info("导出错误:模板信息不存在!");
         }
     }
     catch (Exception e)
     {
         SystemLog.GetInstance().Error(e);
     }
     return savepath;
 }