Page 1 of 1

Multiple file export?

Posted: Thu Mar 17, 2016 10:59 pm
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?

Re: Multiple file export?

Posted: Fri Mar 18, 2016 1:20 pm
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.

Re: Multiple file export?

Posted: Sun Mar 20, 2016 10:56 pm
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.

Re: Multiple file export?

Posted: Mon Mar 21, 2016 7:27 am
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.

Re: Multiple file export?

Posted: Mon Mar 21, 2016 10:00 pm
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.

Re: Multiple file export?

Posted: Tue Mar 22, 2016 10:47 am
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.

Re: Multiple file export?

Posted: Mon Apr 04, 2016 10:53 pm
by midspace
Thankyou for your time.
We will look into this.

Re: Multiple file export?

Posted: Tue Apr 05, 2016 6:35 am
by Alex K.
Hello,

Let us know if you need any additional help.

Thank you.

Re: Multiple file export?

Posted: Fri Feb 16, 2024 10:07 am
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);

Re: Multiple file export?

Posted: Fri Feb 16, 2024 1:34 pm
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.