a370fff216bf459938e7109c71e2481239231a65
FAQ/accessing-izendas-export-process.md
| ... | ... | @@ -8,35 +8,14 @@ How can I utilize Izenda's export process for CSV, PDF, or Excel in an applicati |
| 8 | 8 | |
| 9 | 9 | ##Answer |
| 10 | 10 | |
| 11 | -There are multiple methods to use Izenda's export process in your own application for any export format supported by Izenda. Please refer to the code samples below for examples. |
|
| 11 | +The export process can be invoked by following the code template provided below. The result can be served back to the client computer, to a server filesystem, to a database, or to an email client depending upon the requirements. In the example below, the result is output to the server's filesystem using a directory called "exports" created two levels up from where the program is being executed. |
|
| 12 | 12 | |
| 13 | -###Method 1: ReportRenderer method |
|
| 14 | - |
|
| 15 | -```csharp |
|
| 16 | -foreach (string fileName in Directory.EnumerateFiles(AdHocSettings.ReportsPath)) |
|
| 17 | -{ |
|
| 18 | - reportName = fileName.Substring(fileName.LastIndexOf("\\") + 1, fileName.LastIndexOf(".") - fileName.LastIndexOf("\\") - 1); |
|
| 19 | - try |
|
| 20 | - { |
|
| 21 | - ReportRenderer repRndr = new ReportRenderer(); |
|
| 22 | - byte[] export = repRndr.ExportReportSet(reportName, "PDF"); |
|
| 23 | - File.WriteAllBytes(string.Format("{0}\\{1}.{2}", outputPath, reportName, "PDF"), export); |
|
| 24 | - } |
|
| 25 | - catch (Exception e) |
|
| 26 | - { |
|
| 27 | - message = e.Message; |
|
| 28 | - } |
|
| 29 | - Console.WriteLine(message); |
|
| 30 | -} |
|
| 31 | -``` |
|
| 32 | - |
|
| 33 | -In order to do this with DatabaseAdHocConfig mode, use a data adapter matching your database system's architecture to access the reports within the table that contains the reports. Just having the report names will enable the system to load the reports and their data. |
|
| 34 | - |
|
| 35 | -_*Note:* For PDF exports, this method uses iTextSharp explicitly instead of being dependent upon the [[PdfPrintMode|/API/CodeSamples/PdfPrintMode]] setting._ |
|
| 36 | - |
|
| 37 | -##Method 2: FileContentGenerator method |
|
| 13 | +##Using FileContentGenerator |
|
| 38 | 14 | |
| 39 | 15 | ```csharp |
| 16 | +string outputPath = Path.GetFullPath(string.Format("{0}\\..\\..\\{1}", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "exports")); |
|
| 17 | +if (!Directory.Exists(outputPath)) |
|
| 18 | + Directory.CreateDirectory(outputPath); |
|
| 40 | 19 | foreach (string fileName in Directory.EnumerateFiles(AdHocSettings.ReportsPath)) |
| 41 | 20 | { |
| 42 | 21 | reportName = fileName.Substring(fileName.LastIndexOf("\\"), fileName.LastIndexOf(".") - fileName.LastIndexOf("\\")); |
| ... | ... | @@ -48,10 +27,10 @@ foreach (string fileName in Directory.EnumerateFiles(AdHocSettings.ReportsPath)) |
| 48 | 27 | try |
| 49 | 28 | { |
| 50 | 29 | rs.ReadXml(reportXml); |
| 51 | - Html2PdfGenerator gen = new Html2PdfGenerator(); |
|
| 52 | - FileContentGenerator fileGen = gen.GenerateOutput(rs) as FileContentGenerator; |
|
| 53 | - File.WriteAllBytes(string.Format("{0}\\{1}.{2}", outputPath, fileGen.OutputFileName, "PDF"), fileGen.Content); |
|
| 54 | - message = string.Format("File {0}.pdf written to {1}", fileGen.OutputFileName, outputPath); |
|
| 30 | + Izenda.Controls.Html2PdfGenerator gen = new Izenda.Controls.Html2PdfGenerator(); |
|
| 31 | + Izenda.Controls.FileContentGenerator fileGen = gen.GenerateOutput(rs) as Izenda.Controls.FileContentGenerator; |
|
| 32 | + File.WriteAllBytes(string.Format("{0}\\{1}.{2}", outputPath, fileGen.OutputFileName, gen.FileExtension), fileGen.Content); |
|
| 33 | + message = string.Format("File {0}.{1} written to {2}", fileGen.OutputFileName, gen.FileExtension, outputPath); |
|
| 55 | 34 | } |
| 56 | 35 | catch (Exception e) |
| 57 | 36 | { |
| ... | ... | @@ -60,6 +39,10 @@ foreach (string fileName in Directory.EnumerateFiles(AdHocSettings.ReportsPath)) |
| 60 | 39 | Console.WriteLine(message); |
| 61 | 40 | } |
| 62 | 41 | |
| 63 | -This method provides a bit better control over the process, since it works with the explicitly defined .NET types within the Izenda framework. The previous method requires knowledge of the specific output type codes used and only works with iTextSharp as the PDF export. |
|
| 42 | +There are also other classes that are accessible in the same manner and that inherit from the same interface. Simply replace the Html2PdfGenerator with the necessary class to export to different formats. These classes are defined as follows: |
|
| 64 | 43 | |
| 65 | -Both methods can have their output file saved anywhere on the server that the code has access to, on a database, sent via email, etc. |
|
| ... | ... | \ No newline at end of file |
| 0 | +* CsvReportOutputGenerator |
|
| 1 | +* BulkCsvReportOutputGenerator |
|
| 2 | +* XmlReportOutputGenerator |
|
| 3 | +* ITextSharpPdfGenerator (The Html2PdfGenerator uses EO) |
|
| 4 | +* SqlReportOutputGenerator |
|
| ... | ... | \ No newline at end of file |