Page 1 of 1

Email report in CSV instead of PDF format

PostPosted: Mon Jul 30, 2018 9:29 am
by Ernst
Am scheduling a report via a plugin, but the customer wants the file in CSV format, instead of PDF format.

Has anybody managed to get this to work. Thx.

Im using 7.0.175 and mostly vb .net.

Re: Email report in CSV instead of PDF format  Topic is solved

PostPosted: Mon Jul 30, 2018 10:20 am
by Mike.Sheen
Ernst wrote:Am scheduling a report via a plugin, but the customer wants the file in CSV format, instead of PDF format.

Has anybody managed to get this to work. Thx.

Im using 7.0.175 and mostly vb .net.


Hi Ernst,

If you take a look at this topic, you should be able to just change the the line which reads:
Code: Select all
printReportObject.CrystalReportObject.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, FileName);

To:
Code: Select all
printReportObject.CrystalReportObject.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.CharacterSeparatedValues, FileName);



If the report is a stored procedure based report, then I think it would be vastly more efficient to simply call the stored procedure and write away the results to a csv.

Mike

Re: Email report in CSV instead of PDF format

PostPosted: Tue Jul 31, 2018 10:18 pm
by SBarnes
Hi Ernst

You can actually get ServiceStack to do the heavy lifting to produce the CSV see http://docs.servicestack.net/csv-format if the report is a stored procedure as Mike suggested.

Its T4 Templates can also create the stored procedure code for you, see https://books.google.com.au/books?id=x9hpBgAAQBAJ&pg=PA129&lpg=PA129&dq=servicestack+t4+templates&source=bl&ots=dJ3MSKNy6A&sig=-txxhkU4d-du5ZO85Zynf5GjeRU&hl=en&sa=X&ved=2ahUKEwiB042Rm8ncAhXBdN4KHQsFBLEQ6AEwBnoECAQQAQ#v=onepage&q=servicestack%20t4%20templates&f=false on how to do this.

Re: Email report in CSV instead of PDF format

PostPosted: Sat Aug 04, 2018 6:12 pm
by Mike.Sheen
SBarnes wrote:You can actually get ServiceStack to do the heavy lifting to produce the CSV


Indeed! You can also get ServiceStack to do the same for reading a CSV - as Jiwa now ships (since 7.1) with the ServiceStack libraries, any plugin can leverage that to read a CSV into a List<T> as shown in the plugin "Bendigo Bank Cashbook CSV Imports" included as part of 7.2:

Code: Select all
List<BendigoBankSimpleCSVTransaction> transactions = ServiceStack.Text.CsvSerializer.DeserializeFromString<List<BendigoBankSimpleCSVTransaction>>(sb.ToString());