private void Button_Export_Click(object sender, EventArgs e) { FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog(); if (DialogResult.OK == folderBrowserDialog1.ShowDialog()) { String fullPath = folderBrowserDialog1.SelectedPath; String fileName = Path.Combine(fullPath, string.Format("平行关系对应查询({0}-{1}-{2}).xls", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)); FpSpread.SaveExcel(fileName, IncludeHeaders.ColumnHeadersCustomOnly); MessageBox.Show(string.Format("平行关系对应查询“{0}”导出完成", fileName)); } }
/// <summary> /// 导出周报月报 /// </summary> private void ExportData() { if (_FpSpreed != null) { FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog(); if (DialogResult.OK == folderBrowserDialog1.ShowDialog()) { String fullPath = folderBrowserDialog1.SelectedPath; String fileName = Path.Combine(fullPath, "报表.xls"); _FpSpreed.SaveExcel(fileName, IncludeHeaders.ColumnHeadersCustomOnly); MessageBox.Show(string.Format("“{0}”导出完成", fileName)); } } }
private void ExportExcelFile() { SaveFileDialog FileDialog = new SaveFileDialog(); FileDialog.Filter = "Excel files (*.xls)|*.xls"; FileDialog.FilterIndex = 2; FileDialog.InitialDirectory = Application.StartupPath; FileDialog.RestoreDirectory = true; if (FileDialog.ShowDialog() == DialogResult.OK) { FpSpread fpspread = new FpSpread(); fpspread.Sheets.Add(myCell1.ActiveSheet); fpspread.SaveExcel(FileDialog.FileName); fpspread.Sheets.Clear(); } }
public static Boolean SaveToExcel(Guid documentID, FpSpread fpSpread, String path) { if (fpSpread == null || fpSpread.Sheets.Count == 0) { return(false); } Boolean flag = false; try { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } String filePath = Path.Combine(path, documentID.ToString() + ".xls"); fpSpread.SaveExcel(filePath, FarPoint.Excel.ExcelSaveFlags.NoFormulas | FarPoint.Excel.ExcelSaveFlags.SaveAsViewed); flag = true; } catch { flag = false; } return(flag); }