private void button1_Click(object sender, EventArgs e) { XtraReport1 r = new XtraReport1(); r.CreateDocument(); xtraUserControl11.printControl1.PrintingSystem = r.PrintingSystem; }
private void button1_Click(object sender, EventArgs e) { XtraReport1 r = new XtraReport1(); r.CreateDocument(); ShowControlsOnPage(r, 2); }
internal static void Export(string fileName, XlsExportOptions xlsExportOptions) { XtraReport1 report = new XtraReport1(); nwindDataSet ds = new nwindDataSet(); nwindDataSetTableAdapters.CategoriesTableAdapter cta = new WindowsApplication1.nwindDataSetTableAdapters.CategoriesTableAdapter(); cta.Fill(ds.Categories); report.Category.Value = ds.Categories[0].CategoryID; report.PrintingSystem.ExportOptions.PrintPreview.ShowOptionsBeforeExport = false; report.CreateDocument(); report.ExportToXls(fileName, xlsExportOptions); Excel.Application ObjExcel = new Excel.Application(); Workbook ObjWorkBookGeneral; Worksheet ObjWorkSheet; Workbook ObjWorkBookTemp = ObjExcel.Workbooks.Open(Environment.CurrentDirectory + "\\" + fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); ObjWorkBookGeneral = ObjExcel.Workbooks.Open(Environment.CurrentDirectory + "\\" + fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); ((Worksheet)ObjWorkBookGeneral.Sheets[1]).Name = ds.Categories[0].Description.Length > 30 ? ds.Categories[0].Description.Substring(0, 30) : ds.Categories[0].Description; bool isObjWorkBookTempClosed = false; try { for (int i = 1; i < ds.Categories.Count; i++) { report.Category.Value = ds.Categories[i].CategoryID; report.CreateDocument(); report.ExportToXls("temp_" + fileName + ".xls"); ObjWorkBookTemp = ObjExcel.Workbooks.Open(Environment.CurrentDirectory + "\\temp_" + fileName + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); isObjWorkBookTempClosed = false; ObjWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)ObjWorkBookTemp.Sheets[1]; ObjWorkSheet.Name = ds.Categories[i].Description.Length > 30 ? ds.Categories[i].Description.Substring(0, 30) : ds.Categories[i].Description; ObjWorkSheet.Copy(Type.Missing, ObjWorkBookGeneral.Sheets[ObjWorkBookGeneral.Sheets.Count]); ObjWorkBookTemp.Close(Microsoft.Office.Interop.Excel.XlSaveAction.xlSaveChanges, Type.Missing, Type.Missing); isObjWorkBookTempClosed = true; } } finally { if (!isObjWorkBookTempClosed) { ObjWorkBookTemp.Close(Microsoft.Office.Interop.Excel.XlSaveAction.xlSaveChanges, Type.Missing, Type.Missing); } ObjWorkBookGeneral.Close(Microsoft.Office.Interop.Excel.XlSaveAction.xlSaveChanges, Type.Missing, Type.Missing); ObjExcel.Quit(); File.Delete(Environment.CurrentDirectory + "\\temp_" + fileName + ".xls"); } }
private void button1_Click(object sender, EventArgs e) { XtraReport1 report = new XtraReport1(); report.FilterString = ""; report.CreateDocument(false); ReportPrintTool tool = new ReportPrintTool(report); tool.PrintingSystem.AddCommandHandler(new ExportToXlsCommandHandler()); tool.ShowPreviewDialog(); }