使用FlexViewer控件,您可以预览和导出报表。报表可以导出为多种文件格式:.pdf,.html,.rtf,.docx,.xls,.xlsx,.zip,.tiff,.bmp,.png,.jpg和.gif。以下代码描述了如何使用C1FlexViewer类的Export方法导出FlexReport:
//Load report definition c1FlexReport1.Load(@"reportFile", "reportName"); //Specify the report shown by the viewer c1FlexViewer1.DocumentSource = c1FlexReport1; //Export c1FlexViewer1.Export(); |
以下代码描述了如何使用PdfFilter类将FlexReport导出为PDF 。同样,您也可以将报表导出为上述其他格式。
//create report object C1FlexReport c1FlexReport1 = new C1FlexReport(); //Load a report c1FlexReport1.Load(@"..\..\ProductsReport.flxr", "Products Report"); c1FlexReport1.Render(); //Create PdfFilter object C1.Win.C1Document.Export.PdfFilter filter = new C1.Win.C1Document.Export.PdfFilter(); filter.ShowOptions = false; //Give file name and path where exported file will be saved filter.FileName = "Products Report" + @"..\..\ProductsReport.pdf"; //The report is exported as ProductsReport.pdf in bin\debug folder //Export c1FlexReport1.RenderToFilter(filter); |