Example #1
0
 protected void btn_Export_Click(object sender, EventArgs e)
 {
     DataSet ds = this.GetProductDataSource();
     if (ds.Tables.Count > 0)
     {
         DataTable dt = ds.Tables[0];
         if (dt.Rows.Count > 0)
         {
             //dt.Columns.Remove("Picture");
             ExportExcel ex = new ExportExcel();
             string excelname = "Product";//this.ddl_Type1.SelectedValue;
             excelname += "_view";
             ex.ExportDataSource = dt;
             //excelname = MapPath("FileServer") + "\\" + excelname;//+ ".xls";
             ex.DownloadFileName = excelname;
             string filedownloadurl = MapPath(ConfigurationManager.AppSettings["FileDownloadPath"]) + "\\";
             ex.Download();
         }
         else
         {
             //Response.Write("<script language=javascript>alert('No record!')</script>");
             Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "a", "<script>alert('导出前请先查询数据!');</script>");
         }
     }
     else
     {
         Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "a", "<script>alert('导出前请先查询数据!');</script>");
     }
 }
Example #2
0
 private void ExportBtn_Click(object sender, RoutedEventArgs e)
 {
     if (DataShow.Items.Count > 0)
     {
         ExportExcel.ExportDataGridSaveAs(true, this.DataShow, "倒冲入库记录" + DateTime.Now.ToLongDateString().ToString());
     }
     else
     {
         MessageBox.Show("当前没有可导出的数据!");
     }
 }
Example #3
0
        public static void Init()
        {
            // init variables
            CsvReader.GetData();

            // set initial K -> K = 4 as centroids
            int k = numberOfCentroids;

            for (int i = 0; i < numberOfIterations; i++)
            {
                if (i == 0)
                {
                    //place K Randomly at first time.
                    centroids = Centroid.Initialize(k);
                }

                //eucl distance from centroid to offers / items
                Centroid.CalcCentroidDistance();

                //add data to cluster dictionary
                if (i > 0)
                {
                    Centroid.ClearPointList();
                }
                Centroid.AssignToCluster();

                //vergelijk oude sse met nieuw Sse
                Centroid.UpdateSSE();

                if (i > 0)
                {
                    //relocate centroids
                    centroids = Centroid.CalculateCentroidPosition();
                }
            }

            Silhouette.Init();
            foreach (var cluster in Centroid.sseCentroids)
            {
                var customers = cluster.Value;
                foreach (var customer in customers)
                {
                    Silhouette.CalculateSilhouette(customer.CustomerId);
                }
            }

            PrintResults();
            ExportExcel.Init();
            ExportExcel.CreateClusterWorkSheet();
            ExportExcel.CreateTopDealsWorkSheet();
            ExportExcel.CreateSilhouetteWorkSheet();
            ExportExcel.Export();
            Console.ReadLine();
        }
Example #4
0
        private void BtnReport_Click(object sender, EventArgs e)
        {
            ExportExcel export = new ExportExcel();

            if (!export.ExportArchiveExcel(listView1))
            {
                MessageBox.Show("No se Pudo Guardar la Informacon");
                return;
            }
            MessageBox.Show("Infomacion Guardad -->");
        }
Example #5
0
        /// <summary>
        /// 将符合查询的数据导出Excel
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="grid"></param>
        /// <param name="httplink"></param>
        public void OutputExcel(string filename, ExtjsGrid grid, EntityWLOGWeekSummary wlogweeksummary)
        {
            #region
            int        totalcount  = 0;
            PageParams queryparams = new PageParams(1, 65536);
            DataSet    ds          = this.GetData(wlogweeksummary, queryparams, out totalcount);

            ExportExcel exportexcel = new ExportExcel(filename, ds, grid);
            exportexcel.Output();
            #endregion
        }
Example #6
0
        /// <summary>
        /// 将符合查询的数据导出Excel
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="grid"></param>
        /// <param name="httplink"></param>
        public void OutputExcel(string filename, ExtjsGrid grid, EntityBookPublisher bookpublisher)
        {
            #region
            int        totalcount  = 0;
            PageParams queryparams = new PageParams(1, 65536);
            DataSet    ds          = this.GetData(bookpublisher, queryparams, out totalcount);

            ExportExcel exportexcel = new ExportExcel(filename, ds, grid);
            exportexcel.Output();
            #endregion
        }
        public ActionResult Submit(AssetInventoryViewModel model)
        {
            string action = Request["Submit"];

            if (action == "close")
            {
                if (model.InventoryId > 0)
                {
                    this.AssetInventoryService.UpdateAssetInventoryStatus(model.InventoryId, AssetInventoryStatus.Closed);
                }
            }
            else if (action == "open")
            {
                if (model.InventoryId > 0)
                {
                    this.AssetInventoryService.UpdateAssetInventoryStatus(model.InventoryId, AssetInventoryStatus.Open);
                }
            }
            else if (action == "exportNoScanInfo")
            {
                //导出某次盘点未扫描的资产信息
                try
                {
                    var assetInventory = this.AssetInventoryService.GetAssetInventory(model.InventoryId);
                    var scanedAssetIds = new List <int>();
                    if (assetInventory != null && assetInventory.AssetInventoryRecords != null)
                    {
                        scanedAssetIds = assetInventory.AssetInventoryRecords.Where(it => it.AssetId.HasValue).Select(it => it.AssetId.Value).Distinct().ToList();
                    }
                    var workbook   = new Aspose.Cells.Workbook();
                    var descriptor = new ExportExcel <AssetModel>();

                    AssetSearchModel search = new AssetSearchModel()
                    {
                        BarCode  = null,
                        TypeId   = null,
                        BuyDate  = null,
                        UserName = null
                    };
                    var assets = this.AssetService.List(search).Where(it => !scanedAssetIds.Contains(it.Id)).ToList();
                    descriptor.FillAssetData(assets, workbook, 0);

                    var    ms       = new MemoryStream();
                    string fileName = assetInventory.Title + "(暂未扫描的资产信息)-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx";
                    workbook.Save(ms, Aspose.Cells.SaveFormat.Xlsx);
                    return(File(ms.ToArray(), "application/vnd.ms-excel", fileName));
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                }
            }
            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// 将符合查询的数据导出Excel
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="grid"></param>
        /// <param name="httplink"></param>
        public void OutputExcel(string filename, ExtjsGrid grid, EntityRoleControlFunctionPoint rolecontrolfunctionpoint)
        {
            #region
            int        totalcount  = 0;
            PageParams queryparams = new PageParams(1, 65536);
            DataSet    ds          = this.GetData(rolecontrolfunctionpoint, queryparams, out totalcount);

            ExportExcel exportexcel = new ExportExcel(filename, ds, grid);
            exportexcel.Output();
            #endregion
        }
Example #9
0
        private void OnExportExcel()
        {
            Cursor.Current = Cursors.WaitCursor;
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title  = "Export Excel";
            dlg.Filter = "Excel Files(*.xls,*.xlsx)|*.xls;*.xlsx";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                ExportExcel.ExportThuocXuatHoaDonToExcel(dlg.FileName, dtpkTuNgay.Value, dtpkDenNgay.Value);
            }
        }
Example #10
0
 /// <summary>
 /// 导出Excel
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void BtnShow_Click(object sender, EventArgs e)
 {
     //Maticsoft.Common.DataToExcel excel = new DataToExcel();
     // Gdv_data.AllowPaging = false;
     // Gdv_data.ShowFooter = false;
     AspNetPager1.CurrentPageIndex = 1;
     AspNetPager1.PageSize         = AspNetPager1.RecordCount;
     LoadData();
     ExportExcel.GetExportExcel(Gdv_data, "用户列表");
     AspNetPager1.CurrentPageIndex = 1;
     AspNetPager1.PageSize         = 10;
     LoadData();
 }
 public void export()
 {
     try
     {
         var         result = GetResults("Google", "IDS");
         ExportExcel exp    = new ExportExcel(result);
         exp.ExportToWepResponse(System.Web.HttpContext.Current.Response);
         //result.FirstOrDefault().
     }
     catch (Exception ex)
     {
     }
 }
Example #12
0
        public string exportSource()
        {
            ExportExcel    ee = new ExportExcel();
            List <Product> gi = pg.Products.Where(w => w.IsDelete != -1).ToList();

            ee.exportSource(Server.MapPath("/"), gi);
            JsonResult js = new JsonResult();
            Result     r  = new Result();

            r.succ = true;
            r.msg  = "";
            return(JsonConvert.SerializeObject(r));
        }
Example #13
0
        public string ExcelTask(string date)
        {
            ExportExcel  ee = new ExportExcel();
            List <Group> gi = pg.Groups.Where(w => w.TaskID != "0").ToList();

            ee.ExcelTask(Server.MapPath("/"), GrouplistAll(date));
            JsonResult js = new JsonResult();
            result     r  = new result();

            r.code = "0";
            r.msg  = "";
            return(JsonConvert.SerializeObject(r));
        }
Example #14
0
 private void btnExport_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (ExportExcel.ExportDetailRecordToExcel(txtPidNo.Text, Common.TempFilePath, dgDetailRecords))
         {
             MessageBox.Show("导出成功!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("导出失败,错误:" + ex.Message);
     }
 }
Example #15
0
 private void BtnExport_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (ExportExcel.ExportRecordToExcel("训练信息", Common.TempFilePath, dataGridSisSerch))
         {
             System.Windows.MessageBox.Show("导出已完成!");
         }
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show("导出失败,错误:" + ex.Message);
     }
 }
Example #16
0
        //楼盘面积统计导出
        public void HouseAreaExport(string SSJD, string expwher)
        {
            //获取导出列表
            DataTable dt = BuildingsAndBuildingMonthInfoBLL.GetStatisticsByHouseName(Request["ParaName"]);

            //导出列
            Dictionary <string, string> dicionary = new Dictionary <string, string>
            {
                { "HouseName", "楼盘名称" },
                { "ZJZMJ", "总建筑面积" }
            };

            ExportExcel.Export(dt.ExportExcelPre(dicionary), "楼盘面积统计");
        }
Example #17
0
 public void Existup(DataTable ErrorDt)
 {
     try
     {
         ErrorDt.TableName = "table";
         //string amountFileName = SyntacticSugar.ConfigSugar.GetAppString("Errortabel");
         ExportExcel.ExportExcels("Errortabel.xlsx", "Errortabel.xls", ErrorDt);
         //Common.ExportExcel.ExportExcels("Errortabel.xlsx", amountFileName, ErrorDt);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #18
0
        private void OnExportExcel()
        {
            Cursor.Current = Cursors.WaitCursor;
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title  = "Export Excel";
            dlg.Filter = "Excel Files(*.xls,*.xlsx)|*.xls;*.xlsx";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                DateTime tuNgay  = new DateTime(dtpkTuNgay.Value.Year, dtpkTuNgay.Value.Month, dtpkTuNgay.Value.Day, 0, 0, 0);
                DateTime denNgay = new DateTime(dtpkDenNgay.Value.Year, dtpkDenNgay.Value.Month, dtpkDenNgay.Value.Day, 23, 59, 59);
                ExportExcel.ExportChiDinhDuocXuatHoaDon(dlg.FileName, tuNgay, denNgay);
            }
        }
        public void export(List <WebLink> searchresult)
        {
            try
            {
                //List<WebLink> searchresult;

                ExportExcel exp = new ExportExcel(searchresult);
                exp.ExportToWepResponse(System.Web.HttpContext.Current.Response);
                //result.FirstOrDefault().
            }
            catch (Exception ex)
            {
            }
        }
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;
            string template = string.Empty;

            DateTime tuNgay       = new DateTime(dtpkTuNgay.Value.Year, dtpkTuNgay.Value.Month, dtpkTuNgay.Value.Day, 0, 0, 0);
            DateTime denNgay      = new DateTime(dtpkDenNgay.Value.Year, dtpkDenNgay.Value.Month, dtpkDenNgay.Value.Day, 23, 59, 59);
            string   docStaffGUID = cboDocStaff.SelectedValue.ToString();

            string exportFileName = string.Format("{0}\\Temp\\ThongKeChiDinhCuaBacSi.xls", Application.StartupPath);

            if (isPreview)
            {
                if (!ExportExcel.ExportChiDinhCuaBacSi(exportFileName, tuNgay, denNgay, docStaffGUID))
                {
                    return;
                }

                try
                {
                    ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(template));
                }
                catch (Exception ex)
                {
                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                    return;
                }
            }
            else
            {
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    if (!ExportExcel.ExportChiDinhCuaBacSi(exportFileName, tuNgay, denNgay, docStaffGUID))
                    {
                        return;
                    }

                    try
                    {
                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(template));
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                        return;
                    }
                }
            }
        }
Example #21
0
        private void btnXuatExcel_Click(object sender, EventArgs e)
        {
            SaveFileDialog save = new SaveFileDialog();

            save.Title            = "Nơi chứa file Exprot Excel";
            save.DefaultExt       = "xls";
            save.AddExtension     = true;
            save.Filter           = "File Excel (*.xls)|*.xls";
            save.RestoreDirectory = true;
            save.FileName         = string.Format("ExportExcel_{0}{1:00}{2:00}{3:00}{4:00}{5:00}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            if (save.ShowDialog() == DialogResult.OK)
            {
                ExportExcel.ExportExcelByMicrosoft(dgvKhachHang, "Danh sách khách hàng", save.FileName, 65, "A2");
            }
        }
Example #22
0
 /// <summary>
 /// 导出
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (this.tabStat.SelectedIndex == 0)
     {
         ExportExcel.ExportDataGridSaveAs(true, userStat);
     }
     else if (this.tabStat.SelectedIndex == 1)
     {
         ExportExcel.ExportDataGridSaveAs(true, sumStat);
     }
     else if (this.tabStat.SelectedIndex == 2)
     {
         ExportExcel.ExportDataGridSaveAs(true, weightStat);
     }
 }
Example #23
0
        private void OnExportExcel()
        {
            if (_results == null || _results.Count <= 0)
            {
                return;
            }
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title  = "Export Excel";
            dlg.Filter = "Excel Files(*.xls,*.xlsx)|*.xls;*.xlsx";
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                ExportExcel.ExportDichVuTuTucToExcel(dlg.FileName, _results);
            }
        }
        private void OnExportExcel()
        {
            Cursor.Current = Cursors.WaitCursor;
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title  = "Export Excel";
            dlg.Filter = "Excel Files(*.xls,*.xlsx)|*.xls;*.xlsx";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                DateTime tuNgay       = new DateTime(dtpkTuNgay.Value.Year, dtpkTuNgay.Value.Month, dtpkTuNgay.Value.Day, 0, 0, 0);
                DateTime denNgay      = new DateTime(dtpkDenNgay.Value.Year, dtpkDenNgay.Value.Month, dtpkDenNgay.Value.Day, 23, 59, 59);
                string   docStaffGUID = cboDocStaff.SelectedValue.ToString();
                ExportExcel.ExportChiDinhCuaBacSi(dlg.FileName, tuNgay, denNgay, docStaffGUID);
            }
        }
Example #25
0
 /// <summary>
 /// 导出excel
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void BtnShow_Click(object sender, EventArgs e)
 {
     AspNetPager1.CurrentPageIndex = 1;
     AspNetPager1.PageSize         = AspNetPager1.RecordCount;
     if (AspNetPager1.RecordCount > 6000)
     {
         Maticsoft.Common.MessageBox.Show(this, "超过最大导出数,请先过滤条件后再导出!");
         return;
     }
     LoadData();
     ExportExcel.GetExportExcel(gvStatic, "用户测量数据列表");
     AspNetPager1.CurrentPageIndex = 1;
     AspNetPager1.PageSize         = 50;
     LoadData();
 }
Example #26
0
        private void OnPrint()
        {
            Cursor.Current = Cursors.WaitCursor;
            List <string> checkedReceiptList = new List <string>();
            DataTable     dt = dgReceipt.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    checkedReceiptList.Add(row["ReceiptGUID"].ToString());
                }
            }

            if (checkedReceiptList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn in những phiếu thu mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    string exportFileName = string.Format("{0}\\Temp\\Receipt.xls", Application.StartupPath);
                    foreach (string receiptGUID in checkedReceiptList)
                    {
                        try
                        {
                            if (ExportExcel.ExportReceiptToExcel(exportFileName, receiptGUID))
                            {
                                if (_printDialog.ShowDialog() == DialogResult.OK)
                                {
                                    ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.PhieuThuDichVuTemplate));
                                }
                                //ExcelPrintPreview.PrintPreview(exportFileName);
                            }
                            else
                            {
                                return;
                            }
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những phiếu thu cần in.", IconType.Information);
            }
        }
Example #27
0
        private void OnPrint(bool isPreview)
        {
            if (dgBenhNhan.RowCount <= 0)
            {
                return;
            }
            DataTable dt = dgBenhNhan.DataSource as DataTable;

            if (dt == null || dt.Rows.Count <= 0)
            {
                return;
            }

            string exportFileName = string.Format("{0}\\Temp\\DanhSachBenhNhanDenKham.xls", Application.StartupPath);

            if (isPreview)
            {
                if (ExportExcel.ExportDanhSachBenhNhanDenKhamToExcel(exportFileName, dt, raDenKham.Checked))
                {
                    try
                    {
                        ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.DanhSachBenhNhanDenKhamTemplate));
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                    }
                }
            }
            else
            {
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    if (ExportExcel.ExportDanhSachBenhNhanDenKhamToExcel(exportFileName, dt, raDenKham.Checked))
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.DanhSachBenhNhanDenKhamTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }
                    }
                }
            }
        }
Example #28
0
        /// <summary>
        /// xUẤT  file excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ptbPrintf_Click(object sender, EventArgs e)
        {
            Thread thr = new Thread(() =>
            {
                Invoke((MethodInvoker)(() =>
                {
                    string query = "USP_getListNhanVienReport";
                    DataTable data = DataProvider.Instance.ExecuteQuery(query);
                    ExportExcel.exportDataToExcel("DANH SÁCH NHÂN VIÊN", data);
                }));
            });

            thr.IsBackground = true;

            thr.Start();
        }
Example #29
0
 private void OnExportExcel(string fileName)
 {
     try
     {
         if (_dtSource == null || _dtSource.Rows.Count <= 0)
         {
             return;
         }
         ExportExcel.ExportDichVuXetNghiemToExcel(fileName, _tuNgay, _denNgay, _dtSource);
     }
     catch (Exception ex)
     {
         MsgBox.Show(Application.ProductName, ex.Message, IconType.Error);
         Utility.WriteToTraceLog(ex.Message);
     }
 }
 public HttpResponseMessage Post(string[] filePaths)
 {
     try
     {
         foreach (var item in filePaths)
         {
             ExportExcel excel = new ExportExcel();
             excel.ReadExcelIntoDatatable(item);
         }
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(HttpStatusCode.InternalServerError);
     }
 }
Example #31
0
        public string exportExcel()
        {
            ExportExcel      ee = new ExportExcel();
            List <GroupItem> gi = GetGroupData();

            foreach (var g in gi)
            {
                ee.exportExcel(Server.MapPath("/"), g);
            }
            JsonResult js = new JsonResult();
            result     r  = new result();

            r.code = "0";
            r.msg  = "";
            return(JsonConvert.SerializeObject(r));
        }
    public IWorkbook getWorkbookXLS(string tTitle, string tSubtitle, string tSource, string tKeywords, string tTableData, string tSvg)
    {
        IWorkbook workbook = null;
        try
        {
            string workingDir = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.XLSDownloadType.SvgRasterizerFolder);
            string baticPath = Constants.XLSDownloadType.BatikRasterizerJarFile;
            string templateFilePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.XLSDownloadType.ExcelTemplateFilePath);
            if (File.Exists(templateFilePath))
            {
                Process dosProcess = new Process();
                dosProcess.EnableRaisingEvents = false;
                if (!Page.IsPostBack)
                {
                    ExportExcel exportExcel = new ExportExcel();
                    workbook = SpreadsheetGear.Factory.GetWorkbook(templateFilePath);
                    #region Table tab
                    IWorksheet tableWorksheet = workbook.Worksheets[1];
                    tableWorksheet.Name = "Table";
                    tableWorksheet = exportExcel.getTableWorksheet(tableWorksheet, tTableData, tTitle);
                    #endregion
                    #region Source tab
                    IWorksheet sourceWorksheet = workbook.Worksheets[2];
                    sourceWorksheet.Name = "Source";
                    sourceWorksheet.Cells["A1"].Value = "Source";
                    string[] sourceArray = null;
                    if (!string.IsNullOrEmpty(tSource))
                    {
                        sourceArray = tSource.Split(new string[] { "{}" }, StringSplitOptions.None);
                        int i = 2;
                        foreach (string sourceString in sourceArray)
                        {
                            sourceWorksheet.Cells["A" + i].Value = sourceString;
                            i++;
                        }
                    }
                    #endregion
                    #region Keywords tab
                    IWorksheet keywordWorksheet = workbook.Worksheets[3];
                    keywordWorksheet.Name = "Keywords";
                    keywordWorksheet.Cells["A1"].Value = "Keywords";
                    string[] keywordArray = null;
                    if (!string.IsNullOrEmpty(tKeywords))
                    {
                        keywordArray = tKeywords.Split(new string[] { "{}" }, StringSplitOptions.None);
                        int i = 2;
                        foreach (string keywordString in keywordArray)
                        {
                            keywordWorksheet.Cells["A" + i].Value = keywordString;
                            i++;
                        }
                    }
                    #endregion
                    #region If Svg ImageFormat
                    if (!string.IsNullOrEmpty(tSvg))
                    {
                        string tempFilename = DateTime.Now.ToString();
                        tempFilename = exportExcel.removeInvalidCharacters(tempFilename);
                        string filePath = Path.Combine(workingDir, tempFilename + Constants.XLSDownloadType.SvgExtention);
                        FileStream fileStream = File.Create(filePath);
                        fileStream.Close();
                        using (StreamWriter sw = new StreamWriter(filePath))
                        {
                            sw.Write(tSvg);
                        }
                        # region Image convertion svg to png using Batick
                        /* Convert svg to png using http://xmlgraphics.apache.org/batik/tools/rasterizer.html */

                        string filePth = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @filePath);

                        var sampleDoc = SvgDocument.Open(filePth, new Dictionary<string, string>
                        {
                            {"entity1", "fill:red" },
                            {"entity2", "fill:yellow" }
                        });
                        string destination = @workingDir + "\\" + tempFilename + ".png";
                        sampleDoc.Draw().Save(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, destination));

                        int imageWidth = 470;
                        //string command = "/C java -jar " + baticPath + " " + Constants.XLSDownloadType.ImageType + " " + tempFilename + Constants.XLSDownloadType.SvgExtention;
                        //ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe");
                        //startInfo.UseShellExecute = false;
                        //startInfo.WorkingDirectory = workingDir;
                        //startInfo.Arguments = command;
                        //startInfo.CreateNoWindow = true;
                        //dosProcess.StartInfo = startInfo;
                        //dosProcess.Start();
                        //dosProcess.WaitForExit();
                        //dosProcess.Close();
                        #endregion
                        #region Graph tab
                        string chartImageName = Path.Combine(workingDir, tempFilename);
                        if (File.Exists(chartImageName + Constants.XLSDownloadType.PngExtention))
                        {
                            MemoryStream picStream = new MemoryStream();
                            System.Drawing.Image chartImageObj = System.Drawing.Image.FromFile(chartImageName + Constants.XLSDownloadType.PngExtention);
                            chartImageObj.Save(picStream, ImageFormat.Png);
                            chartImageObj.Dispose();
                            // Graph tab
                            IWorksheet visualizerWorksheet = workbook.Worksheets[0];
                            visualizerWorksheet.Name = "Graph";
                            visualizerWorksheet.Cells["A1"].Value = tTitle;
                            visualizerWorksheet.Cells["A2"].Value = tSubtitle;
                            visualizerWorksheet.Cells["A3"].Value = DateTime.Now.ToString();
                            string baseURL = this.Page.Request.Url.OriginalString.ToString();
                            baseURL = baseURL.Substring(0, baseURL.IndexOf("libraries") - 1);
                            visualizerWorksheet.Cells["A4"].Value = baseURL;
                            visualizerWorksheet.Cells["A1"].Columns.AutoFit();
                            System.Drawing.Image chartImage = System.Drawing.Image.FromStream(picStream);
                            int imageHeight = (int)((imageWidth * chartImage.Height) / chartImage.Width);
                            visualizerWorksheet.Shapes.AddPicture(picStream.ToArray(), 0, 100, (double)imageWidth, (double)imageHeight);
                            picStream.Close();
                            picStream.Dispose();
                            visualizerWorksheet.MoveBefore(workbook.Sheets[0]);
                            //Delete image files.
                            if (File.Exists(chartImageName + Constants.XLSDownloadType.PngExtention))
                            {
                                File.Delete(chartImageName + Constants.XLSDownloadType.PngExtention);
                            }
                            if (File.Exists(chartImageName + Constants.XLSDownloadType.SvgExtention))
                            {
                                File.Delete(chartImageName + Constants.XLSDownloadType.SvgExtention);
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        workbook.Sheets[0].Delete();
                    }
                    # endregion
                    workbook.Sheets[0].Select();
                }
            }
        }
        catch (Exception ex)
        {
            Global.CreateExceptionString(ex, null);
        }
        return workbook;
    }
Example #33
0
 private void BtnExcel_Click(object sender, EventArgs e)
 {
     this.lblMessage.Text = "";
     if (dgvMain.DataSource != null && ((DataTable)(dgvMain.DataSource)).Rows.Count > 0)
     {
         if (strTitle.Equals(""))
         {
             strTitle = "全矿人员 " + cmbYear.SelectedItem.ToString() + "--" + cmbMonth.SelectedItem.ToString() + " 出勤情况明细";
         }
         ExportExcel excel = new ExportExcel();
         string time = string.Format("统计年份:{0} 统计月份:{1}", cmbYear.SelectedItem.ToString(), cmbMonth.SelectedItem.ToString());
         excel.Sql_ExportExcel(GetDataTable(), time, "", strTitle);
     }
     else
     {
         MessageBox.Show("没有可用导出数据!");
     }
 }
Example #34
0
        public ActionResult DownLoadDept()
        {
            string fileName = Server.MapPath("/") + @"Files\Temp\"+"1.xlsx";

            IList<ExcelField> fields=new List<ExcelField>();

            ExcelField ef=null;

            ef=new ExcelField("Code","代码");
            fields.Add(ef);
            ef = new ExcelField("Name", "名字");
            fields.Add(ef);
            ef = new ExcelField("TestExcel", "测试Excel");
            fields.Add(ef);

            TbBaseOper<Department> departmentOper = new TbBaseOper<Department>(HibernateOper, typeof(Department));
            IList<Department> list=departmentOper.Get();

            //ExportExcel ee = new ExportExcel(fileName, "abc", fields);
            ExportExcel ee = new ExportExcel(fileName,typeof(Department));
            ee.Save(list);

            //返回文件
            return File(fileName, "xlsx", "1.xlsx");
        }
Example #35
0
 private void ExpBtn_Click(object sender, EventArgs e)
 {
     QueryObject<Finance> query = new QueryObject<Finance>();
     query.Condition = new Finance();
     query.Condition.BeginTime = this.BeginDate.Value.ToString(Constants.DateFormat);
     query.Condition.EndTime = this.EndDate.Value.ToString(Constants.DateFormat);
     query.Condition.Description = this.Description.Text.Trim();
     query.Condition.EventType = (string)this.EventType.SelectedValue;
     query.Condition.ItemType = (string)this.ItemType.SelectedValue;
     query.Condition.Association = (string)this.Association.SelectedValue;
     query.Condition.ReceivePaymentor = this.ReceivePaymentor.Text.Trim();
     QueryObject<Finance> result = finOrderManager.GetFinances(query);
     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
     saveFileDialog1.Filter = "Excel工作簿(*.xls,*.xlsx)| *.xls; *.xlsx";
     saveFileDialog1.FilterIndex = 2;
     saveFileDialog1.RestoreDirectory = true;
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         string localFilePath = saveFileDialog1.FileName.ToString();
         try
         {
             ExportExcel exporter = new ExportExcel();
             exporter.AddColumn("FinDate", "日期");
             exporter.AddColumn("EventType", "收支类型");
             exporter.AddColumn("Description", "款项说明");
             exporter.AddColumn("Amount", "金额");
             exporter.AddColumn("Rate", "汇率");
             exporter.AddColumn("TotalAmount", "总金额");
             exporter.AddColumn("ReferenceNo", "流水号");
             exporter.AddColumn("ReceivePaymentor", "收付款单位");
             exporter.AddColumn("Association", "经手人/相关人");
             exporter.AddColumn("Remark", "备注");
             exporter.ExportToExcel<Finance>(result.Result, localFilePath);
             exporter.Dispose();
         }
         catch (Exception ex)
         {
             MessageBox.Show("保存文件出错:" + ex.Message);
         }
     }
 }
Example #36
0
        private void ExpBtn_Click(object sender, EventArgs e)
        {
            QueryObject<Order> query = GetQueryObject();
            QueryObject<Order> result = finOrderManager.GetOrders(query);

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.Filter = "Excel工作簿(*.xls,*.xlsx)| *.xls; *.xlsx";
            saveFileDialog1.FilterIndex = 2;
            saveFileDialog1.RestoreDirectory = true;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string localFilePath = saveFileDialog1.FileName.ToString();
                try
                {
                    ExportExcel exporter = new ExportExcel();
                    exporter.AddColumn("BeginDate", "开始日期");
                    exporter.AddColumn("EndDate", "结束日期");
                    exporter.AddColumn("OrderNo", "订单编号");
                    exporter.AddColumn("Description", "订单描述");
                    exporter.AddColumn("SalesMan", "业务员");
                    exporter.AddColumn("Status", "订单状态");
                    if (!IsFinOrderView) {
                        exporter.AddColumn("Remark", "备注");
                    } else {
                        exporter.AddColumn("TotalAmount", "业务总金额");
                    }
                    exporter.ExportToExcel<Order>(result.Result, localFilePath);
                    exporter.Dispose();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("保存文件出错:" + ex.Message);
                }
            }
        }
Example #37
0
 public ActionResult GetImportErrorExcel(string sessionKey, string tableName)
 {
     MemoryCacheManager cacheManager = new MemoryCacheManager();
     ActionResult result = null;
     DataSet ds = ExcelConnection.ImportExcelDataset(sessionKey);
     if (ds != null) {
         PagingDataTable importExcelTable = null;
         if (ds.Tables[tableName] != null) {
             importExcelTable = (PagingDataTable)ds.Tables[tableName];
         }
         PagingDataTable errorTable = (PagingDataTable)importExcelTable.Clone();
         DataRow[] rows = importExcelTable.Select("ImportError<>''");
         foreach (var row in rows) {
             errorTable.ImportRow(row);
         }
         //if (importExcelTable != null) {
             result = new ExportExcel { TableName = string.Format("{0}_{1}", tableName, sessionKey), GridData = errorTable };
         //}
     }
     return result;
 }
 public IWorkbook getWorkbookForSwf(string tTitle, string tSubtitle, string tSource, string tKeywords, string tTableData, string imgData)
 {
     IWorkbook workbook = null;
     MemoryStream picStream = new MemoryStream(Convert.FromBase64String(imgData));
     int imageWidth = 470;
     string templateFilePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath,Constants.XLSDownloadType.ExcelTemplateFilePath);
     ExportExcel exportExcel = new ExportExcel();
     if (File.Exists(templateFilePath))
     {
         workbook = SpreadsheetGear.Factory.GetWorkbook(templateFilePath);
         #region Table tab
         IWorksheet tableWorksheet = workbook.Worksheets[1];
         tableWorksheet.Name = "Table";
         tableWorksheet = exportExcel.getTableWorksheet(tableWorksheet, tTableData, tTitle);
         #endregion
         #region Source tab
         IWorksheet sourceWorksheet = workbook.Worksheets[2];
         sourceWorksheet.Name = "Source";
         sourceWorksheet.Cells["A1"].Value = "Source";
         string[] sourceArray = null;
         if (!string.IsNullOrEmpty(tSource))
         {
             sourceArray = tSource.Split(new string[] { "{}" }, StringSplitOptions.None);
             int i = 2;
             foreach (string sourceString in sourceArray)
             {
                 sourceWorksheet.Cells["A" + i].Value = sourceString;
                 i++;
             }
         }
         #endregion
         #region Keywords tab
         IWorksheet keywordWorksheet = workbook.Worksheets[3];
         keywordWorksheet.Name = "Keywords";
         keywordWorksheet.Cells["A1"].Value = "Keywords";
         string[] keywordArray = null;
         if (!string.IsNullOrEmpty(tKeywords))
         {
             keywordArray = tKeywords.Split(new string[] { "{}" }, StringSplitOptions.None);
             int i = 2;
             foreach (string keywordString in keywordArray)
             {
                 keywordWorksheet.Cells["A" + i].Value = keywordString;
                 i++;
             }
         }
         #endregion
         #region Graph tab
         IWorksheet visualizerWorksheet = workbook.Worksheets[0];
         visualizerWorksheet.Name = "Graph";
         visualizerWorksheet.Cells["A1"].Value = tTitle;
         visualizerWorksheet.Cells["A2"].Value = tSubtitle;
         visualizerWorksheet.Cells["A3"].Value = DateTime.Now.ToString();
         string baseURL = this.Page.Request.Url.OriginalString.ToString();
         baseURL = baseURL.Substring(0, baseURL.IndexOf("libraries") - 1);
         visualizerWorksheet.Cells["A4"].Value = baseURL;
         visualizerWorksheet.Cells["A1"].Columns.AutoFit();
         // Insert Image
         System.Drawing.Image chartImage = System.Drawing.Image.FromStream(picStream);
         int imageHeight = (int)((imageWidth * chartImage.Height) / chartImage.Width);
         visualizerWorksheet.Shapes.AddPicture(picStream.ToArray(), 0, 100, (double)imageWidth, (double)imageHeight);
         visualizerWorksheet.MoveBefore(workbook.Sheets[0]);
         #endregion
         workbook.Sheets[0].Select();
         picStream.Close();
         picStream.Dispose();
     }
     return workbook;
 }
Example #39
0
        private void FinDetailExpBtn_Click(object sender, EventArgs e)
        {
            QueryObject<FinDetails> query = new QueryObject<FinDetails>();
            query.IsExport = true;
            query.Condition = new FinDetails();
            query.Condition.BeginTime = this.BeginDateTxt.Value.ToString(Constants.DateFormat);
            query.Condition.EndTime = this.EndDateTxt.Value.ToString(Constants.DateFormat);
            query.Condition.Description = this.EventNameTxt.Text.Trim();
            query.Condition.EventType = (string)this.EventTypeTxt.SelectedValue;
            query.Condition.ItemType = (string)this.ItemTypeTxt.SelectedValue;
            query.Condition.OrderNo = this.OrderNoTxt.Text.Trim();
            query.Condition.Association = (string)this.AssociationTxt.SelectedValue;
            QueryObject<FinDetails> result = finOrderManager.GetFinDetails(query);

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.Filter = "Excel工作簿(*.xls,*.xlsx)| *.xls; *.xlsx";
            saveFileDialog1.FilterIndex = 2;
            saveFileDialog1.RestoreDirectory = true;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string localFilePath = saveFileDialog1.FileName.ToString();
                try
                {
                    ExportExcel exporter = new ExportExcel();
                    exporter.AddColumn("FinDate","日期");
                    exporter.AddColumn("Description", "描述");
                    exporter.AddColumn("TotalAmount","金额");
                    exporter.AddColumn("OrderNo","所属业务");
                    exporter.AddColumn("ItemType","项目类型");
                    exporter.AddColumn("Association","经手人/相关人");
                    exporter.AddColumn("EventType","收支类型");
                    exporter.AddColumn("Remark","备注");
                    exporter.ExportToExcel<FinDetails>(result.Result, localFilePath);
                    exporter.Dispose();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("保存文件出错:" + ex.Message);
                }
            }
        }