private void cmd_ok_Click(object sender, System.EventArgs e) { if (vs.Row <= 0) { return; } try { string filename = ""; filename = PublicFunction.Path + "\\ReportsVBA\\" + vs.Rows[vs.Row]["FIL_NM"]; string where, where1, where2, where3, where4, where5, where6, where7; where = where1 = where2 = where3 = where4 = where5 = where6 = where7 = ""; where = control1.GetWhere("FILB01A", false); where1 = dt_m.Text; where2 = ((DateTime)dt_dt1.Value).ToString("yyyy/MM/dd"); where3 = ((DateTime)dt_dt2.Value).ToString("yyyy/MM/dd"); where4 = dt_y.Text; where5 = cb_q.Text; where6 = ck_labour.Checked + ""; where7 = ck_vat.Checked + ""; // rp.PrintExcel(filename,PublicFunction.C_ConStrForRPT,vs.Rows[vs.Row][PublicFunction.L_Lag]+"","", // PublicFunction.L_Lag,where,where1,where2,where3,where4,where5,where6,where7,"","","",PublicFunction.A_UserID); ReportExcel.PrintExcel(filename, PublicFunction.C_ConStrForRPT, "", "", PublicFunction.L_Lag, where, where1, where2, where3, where4, where5, where6, where7, "", "", "", "", "", "", PublicFunction.A_UserID); } catch {} }
/// <summary> /// Запрос на выгрузку данных в таблицу XLSX по заданной выборки View /// </summary> /// <param name="sqlSelect">Sql запрос</param> /// <param name="nameFile">Наименование файла</param> /// <param name="nameReport">Наименование отчета</param> /// <param name="pathSaveReport">Путь сохранения отчета</param> /// <returns></returns> public Stream GenerateStreamToSqlViewFile(string sqlSelect, string nameFile, string nameReport, string pathSaveReport) { var sqlConnect = new SqlConnectionType(); var xlsx = new ReportExcel(); var tableTelephone = sqlConnect.ReportQbe(ConnectionString, sqlSelect); xlsx.ReportSave(pathSaveReport, nameFile, nameReport, tableTelephone); return(xlsx.DownloadFile(Path.Combine(pathSaveReport, $"{nameFile}.xlsx"))); }
/// <summary> /// Отчет для СТО выгрузка /// </summary> /// <param name="pathSaveReport">Путь сохранения</param> /// <param name="analysisEpo">Выбранный анализ</param> /// <returns></returns> private byte[] CreateReportEpo(string pathSaveReport, AnalysisEpoAndInventarka analysisEpo) { var xlsx = new ReportExcel(); var sqlConnect = new SqlConnectionType(); var reportAnalysis = sqlConnect.ReportQbe(ConnectionString, analysisEpo.ViewReport); xlsx.ReportAddListFile(analysisEpo.NameListXlsx, reportAnalysis); Dispose(true); xlsx.SaveAsFileXlsx(Path.Combine(pathSaveReport, analysisEpo.NameFileXlsx)); return(xlsx.ReadFileByte(Path.Combine(pathSaveReport, analysisEpo.NameFileXlsx))); }
private void excelWorker_DoWork(object sender, DoWorkEventArgs e) { try { ReportExcel.OutputExcelChk(this.dgvCarTextList, "文本位置-" + DateTime.Now.ToString("yyyy-MM-dd"), e.Argument.ToString()); } catch (Exception exception) { Record.execFileRecord("文本界面->导出到Excel", exception.Message); e.Result = exception.Message; } }
/// <summary> /// Полный анализ данных ЭПО с инвентаризацией запросы можно расширять /// </summary> /// <param name="pathSaveReport"></param> /// <param name="idReport">Уникальные номера отчетов ЭПО</param> /// <returns></returns> public Stream CreateFullReportEpo(string pathSaveReport, int[] idReport) { var xlsx = new ReportExcel(); var sqlConnect = new SqlConnectionType(); var modelsReports = Inventory.AnalysisEpoAndInventarkas.Where(id => idReport.Contains(id.Id)); foreach (var modelReport in modelsReports) { var reportAnalysis = sqlConnect.ReportQbe(ConnectionString, modelReport.ViewReport); xlsx.ReportAddListFile(modelReport.NameListXlsx, reportAnalysis); } Dispose(true); xlsx.SaveAsFileXlsx(Path.Combine(pathSaveReport, "Полный анализ данных.xlsx")); return(xlsx.DownloadFile(Path.Combine(pathSaveReport, "Полный анализ данных.xlsx"))); }
static void Main(string[] args) { clsReport objReport; clsDirector objDirector = new clsDirector(); ReportPDF objRptPdf = new ReportPDF(); objReport = objDirector.MakeReport(objRptPdf); objReport.displayReport(); ReportExcel objRptExcel = new ReportExcel(); objReport = objDirector.MakeReport(objRptExcel); objReport.displayReport(); Console.ReadLine(); }
public void Excel(List <TitleAndQuestions> list, int type) { ReportExcel excel = new ReportExcel(); Response.ClearContent(); Response.Buffer = true; if (type == 1) { Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("content-disposition", "attachment; filename=" + "ExcelDemo.xls"); } excel.GenerateExcel(list, type); Response.End(); Response.Flush(); }
/// <summary> /// Выгрузка сводной таблицы по покупкам из таблицы ReportXlsx /// </summary> /// <param name="pathSaveReport">Путь сохранения</param> /// <param name="inn">ИНН</param> /// <returns></returns> public Stream GenerateSummarySales(string pathSaveReport, string inn) { DataSet dataReport = new DataSet(); var selectProcedureReport = new SelectAll(); var reportModel = selectProcedureReport.ReturnReportModelXlsx(1); var fullPath = Path.Combine(pathSaveReport, reportModel.NameFile); dataReport.Tables.Add(selectProcedureReport.ReturnModelReport(reportModel, inn)); selectProcedureReport.Dispose(); if (dataReport.Tables[0] != null) { var xlsx = new ReportExcel(); xlsx.ReportSaveFullDataSet(fullPath, dataReport); xlsx.Dispose(); return(xlsx.DownloadFile(fullPath)); } return(null); }
private void cmd_ok_Click(object sender, System.EventArgs e) { try { string tenfile = ""; tenfile = vs.Rows[vs.Row]["FIL_NM"].ToString(); if (tenfile == "Rehong_ATM.xltm" || tenfile == "Rehong_ATMNV.xltm" || tenfile == "Rehong_TienMat.xltm" || tenfile == "Rehong_TienMatNV.xltm") { Hashtable hs = new Hashtable(); hs["dateChuyenKhoan"] = ((DateTime)dt_m.Value).ToString("MM/yyyy"); hs["strWhere"] = BuildWhereQuery(); ReportExcel2.TemplateToExcel(tenfile, hs); } else if (tenfile == "Rehong_ThongKeLuong.xltm" || tenfile == "Rehong_ThongKeLuongNV.xltm" || tenfile == "Rehong_TangCaVuot.xltm" || tenfile == "Rehong_TangCaVuotNV.xltm") { Hashtable hs = new Hashtable(); hs["strDateChoose"] = ((DateTime)dt_m.Value).ToString("MM/yyyy"); hs["strWhere"] = BuildWhereQuery(); ReportExcel2.TemplateToExcel(tenfile, hs); } else if (tenfile == "Rehong_BangLuongNgay.xltm" || tenfile == "Rehong_BangLuongNgayNV.xltm") { Hashtable hs = new Hashtable(); hs["strDateChoose"] = ((DateTime)dt_m.Value).ToString("yyyy-MM-dd"); hs["strWhere"] = BuildWhereQuery(); ReportExcel2.TemplateToExcel(tenfile, hs); } else { if (vs.Row <= 0) { return; } string filename = ""; filename = PublicFunction.Path + "\\ReportsVBA\\" + vs.Rows[vs.Row]["FIL_NM"]; string where, where1, where2, where3, where4, where5, where6, where7, where8, where9, where10, where11, where12, where13; where = where1 = where2 = where3 = where4 = where5 = where6 = where7 = where8 = where9 = where10 = where11 = where12 = where13 = ""; string st = "", st1 = "", st2 = "", st3 = "", st4 = ""; if (chk_CUR_DEP.Checked) { st = control1.GetWhere("FILC06AA", false); st = st.Replace("DEP_ID", "DEP_I1"); } else { st = control1.GetWhere("FILB01A", false); } if (st.Length > 255) { st1 = st.Remove(0, 255); st = st.Remove(255, st.Length - 255); if (st1.Length > 255) { st2 = st1.Remove(0, 255); st1 = st1.Remove(255, st1.Length - 255); if (st2.Length > 255) { st3 = st2.Remove(0, 255); st2 = st2.Remove(255, st2.Length - 255); if (st3.Length > 255) { st4 = st3.Remove(0, 255); st3 = st3.Remove(255, st3.Length - 255); } } } } where = st; where1 = dt_m.Text; where2 = ((DateTime)dt_dt1.Value).ToString("yyyy/MM/dd"); where3 = ((DateTime)dt_dt2.Value).ToString("yyyy/MM/dd"); where4 = dt_y.Text; where5 = cb_q.Text; where6 = ck_labour.Checked + ""; where7 = ck_vat.Checked + ""; where8 = this.Tag + ""; where9 = st1; where11 = st2; where12 = st3; //where13=st4; where13 = PublicFunction.GPS.ToString(); where10 = PublicFunction.Path; // ReportExcel.PrintExcel(filename,PublicFunction.C_ConStrForRPT,vs.Rows[vs.Row][PublicFunction.L_Lag]+"","", // PublicFunction.L_Lag,where,where1,where2,where3,where4,where5,where6,where7,where8,where9,where10,PublicFunction.A_UserID); //khoa bao bieu string keyD = ""; string ktype = ""; int iphut = 0; SqlConnection SqlCon1 = new SqlConnection(PublicFunction.C_con.ConnectionString); SqlCon1.Open(); Func.RecordSet rsK = new Func.RecordSet("Select * from GP_KEY", SqlCon1); if (rsK.rows > 0) { ktype = rsK.record(0, "TYP_MN"); keyD = PublicFunction.encode(rsK.record(0, "COL_DT"), ""); iphut = T_String.IsNullTo0(rsK.record(0, "COL_MN")); } if (DateTime.Now >= DateTime.Parse(keyD) && ktype.ToUpper() == "RE") { MessageBox.Show("Office DLL was error"); return; } //end ReportExcel.PrintExcel(filename, PublicFunction.C_ConStrForRPT, vs.Rows[vs.Row][PublicFunction.L_Lag] + "", "", PublicFunction.L_Lag, where, where1, where2, where3, where4, where5, where6, where7, where8, where9, where10, where11, where12, where13, PublicFunction.A_UserID); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// Обработчик события - нажатие клавиши ЭКСПОРТ /// </summary> /// <param name="sender">Объект, инициировавший событие</param> /// <param name="ev">Аргумент события</param> void PanelTaskReaktivka_ClickExport(object sender, EventArgs e) { m_reportExcel = new ReportExcel();// m_reportExcel.CreateExcel(m_dgvValues, Session.m_DatetimeRange); }
private void cmd_ok_Click(object sender, System.EventArgs e) { try { string tenfile = ""; tenfile = vs.Rows[vs.Row]["FIL_NM"].ToString(); if (tenfile == "fvn_Test01.xltm") { Hashtable hs = new Hashtable(); hs["dateFrom"] = ((DateTime)dt_dt1.Value).ToString("yyyy-MM-dd"); hs["dateTo"] = ((DateTime)dt_dt2.Value).ToString("yyyy-MM-dd"); ReportExcel2.TemplateToExcel(tenfile, hs); } else if (tenfile == "Rehong_DanhSachTangCa.xltm") { DateTime dateTimeFrom = Convert.ToDateTime(dt_dt1.Text); DateTime dateTimeTo = Convert.ToDateTime(dt_dt2.Text); object dtResult = dateTimeTo.Subtract(dateTimeFrom); Hashtable hs = new Hashtable(); hs["strBoPhan"] = control1.CB_DEP.Text.ToString(); //bophan; hs["dateTimeFrom"] = dateTimeFrom.ToString("HH:mm"); //time from; hs["dateTimeTo"] = dateTimeTo.ToString("HH:mm"); //time to; hs["WorkHour"] = ((System.TimeSpan)(((TimeSpan)dtResult))).TotalHours.ToString(); ReportExcel2.TemplateToExcel(tenfile, hs); } else if (tenfile == "Rehong_TheNhanVien.xltm" || tenfile == "Rehong_TheNhanVienNV.xltm") { Hashtable hs = new Hashtable(); hs["strWhere"] = BuildWhereQuery(); ReportExcel2.TemplateToExcel(tenfile, hs); } else { if (vs.Row <= 0) { return; } string filename = ""; string st = "", st1 = "", st2 = "", st3 = "", st4 = ""; filename = PublicFunction.Path + "\\ReportsVBA\\" + vs.Rows[vs.Row]["FIL_NM"]; string where, where1, where2, where3, where4, where5, where6, where7, where8, where9, where10, where11, where12, where13; where = where1 = where2 = where3 = where4 = where5 = where6 = where7 = where8 = where9 = where10 = where11 = where12 = where13 = ""; if (chk_CUR_DEP.Checked) { st = control1.GetWhere("m", false); st = st.Replace("DEP_ID", "DEP_I1"); } else { st = control1.GetWhere("FILB01A", false); } if (st.Length > 255) { st1 = st.Remove(0, 255); st = st.Remove(255, st.Length - 255); if (st1.Length > 255) { st2 = st1.Remove(0, 255); st1 = st1.Remove(255, st1.Length - 255); if (st2.Length > 255) { st3 = st2.Remove(0, 255); st2 = st2.Remove(255, st2.Length - 255); if (st3.Length > 255) { st4 = st3.Remove(0, 255); st3 = st3.Remove(255, st3.Length - 255); } } } } where = st; where1 = dt_m.Text; where2 = ((DateTime)dt_dt1.Value).ToString("yyyy/MM/dd"); where3 = ((DateTime)dt_dt2.Value).ToString("yyyy/MM/dd"); where4 = dt_y.Text; where5 = cb_q.Text; where6 = ck_labour.Checked + ""; where7 = ck_vat.Checked + ""; where8 = this.Tag + ""; where9 = st1; where11 = st2; where12 = st3; //where13=st4; where13 = PublicFunction.GPS.ToString(); where10 = PublicFunction.Path; string xmlname = vs.Rows[vs.Row]["FIL_NM"] + ""; //Thu sua lam the bang C1Report if (xmlname.Substring(xmlname.Length - 3, 3) == "xml") { filename = PublicFunction.Path + "\\Reports\\" + vs.Rows[vs.Row]["FIL_NM"]; frmPrintCard dlg = new frmPrintCard(st, filename, xmlname.Substring(0, xmlname.Length - 4)); dlg.Tag = this.Tag; dlg.ShowDialog(); return; } //end Thu // rp.PrintExcel(filename,PublicFunction.C_ConStrForRPT,vs.Rows[vs.Row][PublicFunction.L_Lag]+"","", // PublicFunction.L_Lag,where,where1,where2,where3,where4,where5,where6,where7,where8,where9,where10,PublicFunction.A_UserID); //khoa bao bieu string keyD = ""; string ktype = ""; int iphut = 0; SqlConnection SqlCon1 = new SqlConnection(PublicFunction.C_con.ConnectionString); SqlCon1.Open(); Func.RecordSet rsK = new Func.RecordSet("Select * from GP_KEY", SqlCon1); if (rsK.rows > 0) { ktype = rsK.record(0, "TYP_MN"); keyD = PublicFunction.encode(rsK.record(0, "COL_DT"), ""); iphut = T_String.IsNullTo0(rsK.record(0, "COL_MN")); } if (DateTime.Now >= DateTime.Parse(keyD) && ktype.ToUpper() == "RE") { MessageBox.Show("Office DLL was error"); return; } //end ReportExcel.PrintExcel(filename, PublicFunction.C_ConStrForRPT, vs.Rows[vs.Row][PublicFunction.L_Lag] + "", "", PublicFunction.L_Lag, where, where1, where2, where3, where4, where5, where6, where7, where8, where9, where10, where11, where12, where13, PublicFunction.A_UserID); } } catch (Exception ex) {} }
/// <summary> /// Обработчик события - Кнопка экспорта даных в Excel /// </summary> /// <param name="sender">объект, вызвавщий событие</param> /// <param name="e">Аргумент события, описывающий состояние элемента</param> private void panelManagemenet_btnExportExcel_onClick(object sender, EventArgs e) { m_rptExcel = new ReportExcel(); m_rptExcel.CreateExcel(ActiveDataGridView, Session.m_DatetimeRange); }
private void excelWorker_DoWork(object sender, DoWorkEventArgs e) { ReportExcel.OutputExcel(this.dgvQueryResult, " 日期查车报表 ", e.Argument.ToString(), "日期查车报表", true); }