About Save and Load

Stimulsoft Reports.Silverlight discussion
shaome
Posts: 37
Joined: Mon Aug 01, 2011 9:37 pm
Location: china

About Save and Load

Post by shaome »

Hi, I save a report to string ,but how can I load it?

StiReport report = new StiReport();
string doc=report.SaveDocumentToString();

we save the string 'doc' to database,how can I load the string 'doc'?

the follow code does not work!why
StiReport report = new StiReport();
report.LoadDocumentFromString(doc);
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: About Save and Load

Post by Alex K. »

Hello,

The SaveDocumentToString() method save rendered report. Please try to call the Render() method before saving. If you need save/load a report template please try to use the SaveToString() and LoadFromString() methods.

Thank you.
shaome
Posts: 37
Joined: Mon Aug 01, 2011 9:37 pm
Location: china

Re: About Save and Load

Post by shaome »

Hi,I just want to save/load the rendered report,it does not work!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: About Save and Load

Post by Alex K. »

Hello,

Can you please send us a sample project which reproduce the issue for analysis.

Thank you.
shaome
Posts: 37
Joined: Mon Aug 01, 2011 9:37 pm
Location: china

Re: About Save and Load

Post by shaome »

Hi
Xaml code:
<SLControl:StiSLViewerControl Grid.Column="1" Grid.Row="0" Grid.RowSpan="3" Margin="0,0,0,0" Name="slview" />

CS Code:
------------------------------------------------
//slview load a report from Resource

StiReport report = new StiReport();
report=slview.Report;
report.Render();
string tmpstr=report.SaveDocumentToString();
//save tmpstr to database
----------------------

another page:
Xaml code:
<SLControl:StiSLViewerControl Grid.Column="1" Grid.Row="0" Grid.RowSpan="3" Margin="0,0,0,0" Name="slview" />

CS Code:
----------------
string tmpstr ="xxx"; //Getting the string from database
string reportstring=tmpstr;
StiReport report = new StiReport();
report.LoadDocumentFromString(reportstring);
report.Render();
slview.Report=report;
---------------------------------

///slview can not display the report
shaome
Posts: 37
Joined: Mon Aug 01, 2011 9:37 pm
Location: china

Re: About Save and Load

Post by shaome »

Hi:
I want to save/load a report document, not template.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: About Save and Load

Post by Alex K. »

Hello,

Can you please send us a sample project which reproduce the issue for analysis.

Thank you.
shaome
Posts: 37
Joined: Mon Aug 01, 2011 9:37 pm
Location: china

Re: About Save and Load

Post by shaome »

Hi,I have send the sample to you.
thanks.
Last edited by shaome on Mon Nov 25, 2013 3:16 pm, edited 1 time in total.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: About Save and Load

Post by HighAley »

Hello.

You shouldn't call Render() method in the btnDisPlay_Click event. You create empty report and load rendered report. And when you call Render() method all rendered pages are removed and you get empty report. The right code will look like:

Code: Select all

        private void btnDisPlay_Click(object sender, RoutedEventArgs e)
        {
            if (DocumentString != "")
            {
                StiReport report = new StiReport();
                report.LoadDocumentFromString(DocumentString);
                //report.CalculationMode = StiCalculationMode.Compilation;
                //report.Render();
                stiSLViewerControl2.Report = report;
            }
        }
Thank you.
shaome
Posts: 37
Joined: Mon Aug 01, 2011 9:37 pm
Location: china

Re: About Save and Load

Post by shaome »

thanks
Locked