/// <summary> /// /// </summary> /// <param name="dgv"></param> static public void Export(string filename, DataGridView dgv, DataFormatterCollection dataFormatters, bool isOpenFile) { if (dgv == null) { throw new ArgumentNullException("dgv"); } DataGridViewExcelExporter ee = new DataGridViewExcelExporter(dgv, null, dataFormatters); ee.Export(); ee.Save(filename); if (isOpenFile) { ProcessStartInfo si = new ProcessStartInfo(filename); si.ErrorDialog = true; Process process = new Process(); process.StartInfo = si; try { process.Start(); } catch (Exception ex) { NUnit.UiKit.UserMessage.DisplayFailure(ex.Message); } process.Dispose(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ucSelectCondition1_ExportEvent(object sender, EventArgs e) { string filename = Xdgk.Common.Path.GetTempFileName("xls"); //Xdgk.Common.Export.ExcelExporter ee = new Xdgk.Common.Export.ExcelExporter(filename); //ee.Export(this.dataGridView1); DataFormatterCollection dfs = new DataFormatterCollection(); dfs.Add(new SingleFormatter()); dfs.Add(new Int32Formatter()); dfs.Add(new DoubleFormatter()); Xdgk.Common.Export.Exporter.Export(filename, this.dataGridView1, dfs, true); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ucCalcHeatCondition1_ExportEvent(object sender, EventArgs e) { string filename = CZGRCommon.Path.GetTempFileName("xls"); DataFormatterCollection dfs = new DataFormatterCollection(); dfs.Add(new SingleFormatter()); dfs.Add(new DoubleFormatter()); dfs.Add(new Int32Formatter()); CZGRCommon.ExcelExporter ee = new CZGRCommon.ExcelExporter(filename, dfs); // 耗热量计算公式 // LinesAttache aaa = new LinesAttache(); DataTable tbl = CZGRQRCApp.Default.DBI.ExecuteHeatCommentDataTable(); List<III> iiis = CreateIIIs(); CZGRCommon.CCC ccc = CreateCCC(iiis); aaa.Lines.Add(""); aaa.Lines.Add("注:"); foreach (DataRow row in tbl.Rows) { string content = row["content"].ToString().Trim(); if (content.Length > 0) { aaa.Lines.Add(content); } } //aaa.Lines.Add("\t注:日耗热量 = 日流量 * ( 一次供温 - 一次回温 ) * 4.1816 / 1000"); ee.AttacheCollection.Add(aaa); ee.Export(this.dataGridView1, ccc); ProcessStartInfo si = new ProcessStartInfo(filename); si.ErrorDialog = true; Process.Start(si); }
/// <summary> /// /// </summary> /// <returns></returns> private DataFormatterCollection GetDataFormatterCollection() { DataFormatterCollection s = new DataFormatterCollection(); s.Add(new SingleFormatter()); s.Add(new Int32Formatter()); //s.Add(); return s; }
/// <summary> /// /// </summary> public DataGridViewExcelExporter(DataGridView dgv, FlexCel.XlsAdapter.XlsFile xlsFile, DataFormatterCollection dataFormatterCollection) { if (dgv == null) { throw new ArgumentNullException("dgv"); } this._dgv = dgv; this._xlsFile = xlsFile; this.DataFormatterCollection = dataFormatterCollection; }