Export to txt > modify extension?

Stimulsoft Reports.NET discussion
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Export to txt > modify extension?

Post by Jennypi »

Hello!

I need my users to export a report to txt, in order to import the file into another software.
This other software only accept the files with the extension ".pthosis".

I have 2 questions :
- is there a way to save as text with the extension .pthosis, without the .txt?
- is there a way to automatically run the export dialog after the user click the button in the form? For example, a form like below would do 2 things:
  • - display the report page #1
    - and export the report page #2 as text (is there a way to predefine the file name?)
stimulsoft.png
stimulsoft.png (3.5 KiB) Viewed 4164 times
I'm joining an example with data.

Thank you for your help!
Attachments
data.csv
(9.65 KiB) Downloaded 270 times
Pthosis.mrt
(61.86 KiB) Downloaded 311 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Export to txt > modify extension?

Post by HighAley »

Hello.

Could you specify when you need to show this window? Before export or before showing the report?
You could export the report in code to stream and then save the report with necessary name and extension.

Thank you.
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Re: Export to txt > modify extension?

Post by Jennypi »

Hello,

Here is how I imagine it could work:
1. the user opens the report
2. the report displays the user form
3. the user chooses the list, the requester, and then click "Display and export" button
> Stimulsoft would then do 2 things:
- display the "save as" dialog, so that the user can save the page#2 with the pthosis extension
- and when the dialog is closed, display the page #1.

Does it make sense to you? I'm open to other solutions :) the most important part is that the user needs to be able to export the page#2 with the pthosis extension.

Sorry but I don't understand what you mean by "You could export the report in code to stream and then save the report with necessary name and extension".
I don't use the coding part of Stimulsoft, I'm only using the designer, sorry :(

Thank you.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Export to txt > modify extension?

Post by HighAley »

Hello.

We have a suggestion for you.
In the EndRender event of the report:
1. Go throw rendered pages where you could disable first page.
2. Export the report in text format to stream.
3. show Save dialog to select file name.
4. Save exported report from stream to file
5. Enable first page and disable second page in rendered pages.

Thank you.
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Re: Export to txt > modify extension?

Post by Jennypi »

Hello,

Thanks but again, I don't code, so I don't know how to do that with the designer :(
What do you call "stream"?
How do I call the save dialog?
Ideally, could you please provide me with an example?

Thanks a lot.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Export to txt > modify extension?

Post by HighAley »

Hello, Jenny.

We need some additional time to prepare a sample for you.

Thank you.
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Re: Export to txt > modify extension?

Post by Jennypi »

Thanks a lot for your help :)
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Export to txt > modify extension?

Post by HighAley »

Hello.

Sorry for delay with answer.
We need more time to prepare a sample for you.

Thank you.
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Re: Export to txt > modify extension?

Post by Jennypi »

OK thanks, let me know.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Export to txt > modify extension?

Post by HighAley »

Hello.

We use next code in the End Render event of the report.

Code: Select all

SaveFileDialog sf = new SaveFileDialog();
sf.Title = "Save pthosis file";
sf.Filter = "pthosis file (*.pthosis)|*.pthosis";
var result = sf.ShowDialog();

if (result == System.Windows.Forms.DialogResult.OK)
{
    FileStream fs = new FileStream(sf.FileName, FileMode.Create, FileAccess.Write);
    this.ExportDocument(StiExportFormat.Text, fs, new StiTxtExportSettings() { PageRange = new StiPagesRange(1) });
    fs.Close();
}
this.RenderedPages.RemoveAt(1);
In this code we export the second page (its index is 1). Then remove it.

Thank you.
Attachments
Pthosis modified.mrt
(62.44 KiB) Downloaded 317 times
Post Reply