Multiple file export?

Stimulsoft Ultimate discussion
Post Reply
User avatar
midspace
Posts: 25
Joined: Tue Sep 10, 2013 12:20 am
Location: Melbourne, Australia

Multiple file export?

Post by midspace »

We've just had a request to add a feature to our software and we're unsure if Stimulsoft can do it.
That is a Multiple file export similar to how a Word Mail merge works. (Correction: How it used to work in much older versions.)
That is, taking a single data set with multiple customer records, and merging the data with the template, to export to a multiple files based on each row of customer data.

I haven't had a chance to look at the Stimulsoft API, but I haven't seen any hint that this can be done with searches on the forum and google.

I can only think that there needs to be a page break defined in the template to provide flow control during the processing, but whether it can be done is my first question,
followed by how can it be done?
Last edited by midspace on Sun Mar 20, 2016 10:57 pm, edited 1 time in total.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Multiple file export?

Post by Alex K. »

Hello,

Can you please clarify which product and which technology do you use. Also, please clarify where do you want to add it in our viewer or in your application?

Thank you.
User avatar
midspace
Posts: 25
Joined: Tue Sep 10, 2013 12:20 am
Location: Melbourne, Australia

Re: Multiple file export?

Post by midspace »

We currently use .Net 4.0 and 4.5, in Windows Forms and WPF, with applications written in C#.
Our licence covers the Stimulsoft Report Ultimate product suite.

I do not have any expectation of the Stimulsoft viewer been capable of processing a mail merge to multiple files.
But been able to process and split the resultant report output within our application would be desirable.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Multiple file export?

Post by HighAley »

Hello.

Sorry, but still don't understand your task.
Could you describe your scenario in details?

Do you need to merge different reports in one and then send is by email?
If you need this, you could use next code to merge rendered reports and then export them:

Code: Select all

            // Open and render report in Millimeters
            StiReport sourceReport = new StiReport();
            sourceReport.Load(@"d:\Millimeters.mrt");
            sourceReport.Compile();
            sourceReport.Render();

            // Now create report in Centimeters and copy rendered page from the first report
            StiReport report = new StiReport();
            report.NeedsCompiling = false;
            report.IsRendered = true;
            report.ReportUnit = StiReportUnitType.Centimeters;

            Stimulsoft.Report.Units.StiUnit newUnit = Stimulsoft.Report.Units.StiUnit.GetUnitFromReportUnit(report.ReportUnit);
            Stimulsoft.Report.Units.StiUnit oldUnit = Stimulsoft.Report.Units.StiUnit.GetUnitFromReportUnit(sourceReport.ReportUnit);
            bool needConvert = report.ReportUnit != sourceReport.ReportUnit;

            report.RenderedPages.Clear();
            foreach (StiPage page in sourceReport.CompiledReport.RenderedPages)
            {
                page.Report = report;
                page.NewGuid();
                if (needConvert) page.Convert(oldUnit, newUnit);
                report.RenderedPages.Add(page);
            }

            report.Show();
Thank you.
User avatar
midspace
Posts: 25
Joined: Tue Sep 10, 2013 12:20 am
Location: Melbourne, Australia

Re: Multiple file export?

Post by midspace »

HighAley wrote:Hello.

Sorry, but still don't understand your task.
Could you describe your scenario in details?

Take a single data set with multiple customer records.

Merge the data with a single Stimulsoft template.

Process the report.

Export to one file per row of customer data.

To create as many .pdf files as there are customer records.
Each file should only contain that portion of the report relevant to that customer.


Ie.,

Data (contains 3 records):
Fred Smith, 1 Abc street, $10000
Adam Jones, 2 Zebra Road, $8000
John King, 88 Future Ave, $3000


Report (results in 3 pages):

Page 1:
Dear Fred Smith.
Address: 1 Abc street
Your invoice of $10000 is due.

Page 2:
Dear Adam Jones.
Address: 2 Zebra Road
Your invoice of $8000 is due.

Page 3:
Dear John King.
Address: 88 Future Ave
Your invoice of $3000 is due.


Export (results in 3 files):
Invoice_Fred_Smith_001.pdf
Invoice_Adam_Jones_001.pdf
Invoice_John_King_001.pdf


I hope this is clear.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Multiple file export?

Post by Alex K. »

Hello,

As a way, you can set the ExcelSheet property for the Page as customer name value and use the following code:

Code: Select all

rep.Load();
rep.Compile();
rep.Render();

var customer = rep.RenderedPages[0].ExcelSheetValue;

var exportReport = new StiReport();
exportReport.NeedsCompiling = false;
exportReport.IsRendered = true;
exportReport.RenderedPages.Clear();

foreach (StiPage page in rep.RenderedPages)
{
    if (customer == page.ExcelSheetValue)
    {
        exportReport.RenderedPages.Add(page);
    }
    else
    {
        exportReport.ExportDocument(StiExportFormat.Pdf, "e:\\" + customer + ".pdf");
        
        customer = page.ExcelSheetValue;
        exportReport.RenderedPages.Clear();
        exportReport.RenderedPages.Add(page);
    }
}
...
Thank you.
User avatar
midspace
Posts: 25
Joined: Tue Sep 10, 2013 12:20 am
Location: Melbourne, Australia

Re: Multiple file export?

Post by midspace »

Thankyou for your time.
We will look into this.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Multiple file export?

Post by Alex K. »

Hello,

Let us know if you need any additional help.

Thank you.
audiomedia
Posts: 2
Joined: Wed Jan 10, 2024 7:44 am

Re: Multiple file export?

Post by audiomedia »

Hi !
I need a multiple export of PDF, in javascript. I tried, but i cannot succeed. Can you help me ?
I have a report showing in the viewer, I know how to add a button to have a special action, and I want it to be a download of each page of that report in a separate PDF file .
Can you give me an example please ?
thanks in advance!

I managed to do something but I had to use a timer... can you tell me how not ?

Code: Select all

setTimeout(() => {
      resolve();
 },  200);
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Multiple file export?

Post by Lech Kulikowski »

Hello,

Something like:

Code: Select all

report.Render();
var exportReport = new StiReport();
foreach (StiPage page in report.RenderedPages)
{
    exportReport.RenderedPages.Clear();
    exportReport.RenderedPages.Add(page);

    exportReport.ExportDocument("");
}
Thank you.
Post Reply