Beispiel #1
0
 protected void bExcel_Click(object sender, ImageClickEventArgs e)
 {
     lock (Database.lockObjectDB)
     {
         System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture;
         System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
         string  doc = "";
         ExcelAp ep  = new ExcelAp();
         if (ep.RunApp(ConfigurationSettings.AppSettings["DocPath"] + "Empty.xls"))
         {
             ep.SetWorkSheet(1);
             ep.ExportGridExcel(gvCouriers);
             if (WebConfigurationManager.AppSettings["DocPath"] != null)
             {
                 doc = String.Format("{0}Temp\\catalog.xls", WebConfigurationManager.AppSettings["DocPath"]);
                 ep.SaveAsDoc(doc, false);
             }
         }
         ep.Close();
         GC.Collect();
         System.Threading.Thread.CurrentThread.CurrentCulture = oldCI;
         if (doc.Length > 0)
         {
             ep.ReturnXls(Response, doc);
         }
     }
 }
Beispiel #2
0
        protected void bExcel_Click(object sender, ImageClickEventArgs e)
        {
            lock (Database.lockObjectDB)
            {
                DataSet ds1 = new DataSet();
                string  str = lbSearch.Text.Trim();
                if (str.Length > 0)
                {
                    str += "and " + branchSearch;
                }
                else
                {
                    str += "where " + branchSearch;
                }

                res = Database.ExecuteQuery(String.Format("select * from V_Cards {0} {1}", str, lbSort.Text), ref ds1, null);

                if (ds1 == null || ds1.Tables.Count == 0)
                {
                    return;
                }
                System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture;
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                string  doc = "";
                ExcelAp ep  = new ExcelAp();
                if (ep.RunApp(ConfigurationSettings.AppSettings["DocPath"] + "Empty.xls"))
                {
                    ep.SetWorkSheet(1);
                    ep.ExportGridExcel_Cards(gvCard, ds1.Tables[0]);
                    if (WebConfigurationManager.AppSettings["DocPath"] != null)
                    {
                        doc = String.Format("{0}Temp\\cards.xls", WebConfigurationManager.AppSettings["DocPath"]);
                        ep.SaveAsDoc(doc, false);
                    }
                }
                ep.Close();
                GC.Collect();
                System.Threading.Thread.CurrentThread.CurrentCulture = oldCI;
                if (doc.Length > 0)
                {
                    ep.ReturnXls(Response, doc);
                }
            }
        }